2020-01-20 20:56:06 +00:00
|
|
|
package wakuext
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/syndtr/goleveldb/leveldb"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
"github.com/status-im/status-go/params"
|
|
|
|
"github.com/status-im/status-go/services/ext"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Service struct {
|
|
|
|
*ext.Service
|
|
|
|
w types.Waku
|
|
|
|
}
|
|
|
|
|
2022-01-12 16:02:01 +00:00
|
|
|
func New(config params.NodeConfig, n types.Node, handler ext.EnvelopeEventsHandler, ldb *leveldb.DB) *Service {
|
2021-06-30 11:40:54 +00:00
|
|
|
w, err := n.GetWaku(nil)
|
2020-01-20 20:56:06 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
delay := ext.DefaultRequestsDelay
|
2022-01-12 16:02:01 +00:00
|
|
|
if config.ShhextConfig.RequestsDelay != 0 {
|
|
|
|
delay = config.ShhextConfig.RequestsDelay
|
2020-01-20 20:56:06 +00:00
|
|
|
}
|
|
|
|
requestsRegistry := ext.NewRequestsRegistry(delay)
|
|
|
|
mailMonitor := ext.NewMailRequestMonitor(w, handler, requestsRegistry)
|
|
|
|
return &Service{
|
2021-05-13 13:30:33 +00:00
|
|
|
Service: ext.New(config, n, ldb, mailMonitor, w),
|
2020-01-20 20:56:06 +00:00
|
|
|
w: w,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Service) PublicWakuAPI() types.PublicWakuAPI {
|
|
|
|
return s.w.PublicWakuAPI()
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIs returns a list of new APIs.
|
|
|
|
func (s *Service) APIs() []rpc.API {
|
|
|
|
apis := []rpc.API{
|
|
|
|
{
|
|
|
|
Namespace: "wakuext",
|
|
|
|
Version: "1.0",
|
|
|
|
Service: NewPublicAPI(s),
|
2020-02-25 07:03:01 +00:00
|
|
|
Public: false,
|
2020-01-20 20:56:06 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
return apis
|
|
|
|
}
|