2021-06-16 20:19:45 +00:00
|
|
|
package wakuv2ext
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/syndtr/goleveldb/leveldb"
|
|
|
|
|
2022-06-02 12:17:52 +00:00
|
|
|
gethrpc "github.com/ethereum/go-ethereum/rpc"
|
2021-06-16 20:19:45 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
"github.com/status-im/status-go/params"
|
2022-06-02 12:17:52 +00:00
|
|
|
"github.com/status-im/status-go/rpc"
|
2021-06-16 20:19:45 +00:00
|
|
|
"github.com/status-im/status-go/services/ext"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Service struct {
|
|
|
|
*ext.Service
|
|
|
|
w types.Waku
|
|
|
|
}
|
|
|
|
|
2022-06-02 12:17:52 +00:00
|
|
|
func New(config params.NodeConfig, n types.Node, rpcClient *rpc.Client, handler ext.EnvelopeEventsHandler, ldb *leveldb.DB) *Service {
|
2021-06-30 11:40:54 +00:00
|
|
|
w, err := n.GetWakuV2(nil)
|
2021-06-16 20:19:45 +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
|
2021-06-16 20:19:45 +00:00
|
|
|
}
|
|
|
|
requestsRegistry := ext.NewRequestsRegistry(delay)
|
|
|
|
mailMonitor := ext.NewMailRequestMonitor(w, handler, requestsRegistry)
|
|
|
|
return &Service{
|
2022-06-02 12:17:52 +00:00
|
|
|
Service: ext.New(config, n, rpcClient, ldb, mailMonitor, w),
|
2021-06-16 20:19:45 +00:00
|
|
|
w: w,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Service) PublicWakuAPI() types.PublicWakuAPI {
|
|
|
|
return s.w.PublicWakuAPI()
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIs returns a list of new APIs.
|
2022-06-02 12:17:52 +00:00
|
|
|
func (s *Service) APIs() []gethrpc.API {
|
|
|
|
apis := []gethrpc.API{
|
2021-06-16 20:19:45 +00:00
|
|
|
{
|
|
|
|
Namespace: "wakuext",
|
|
|
|
Version: "1.0",
|
|
|
|
Service: NewPublicAPI(s),
|
|
|
|
Public: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return apis
|
|
|
|
}
|