github.com/status-im/status-go@v1.1.0/services/wakuv2ext/service.go (about)

     1  package wakuv2ext
     2  
     3  import (
     4  	"github.com/syndtr/goleveldb/leveldb"
     5  
     6  	gethrpc "github.com/ethereum/go-ethereum/rpc"
     7  	"github.com/status-im/status-go/eth-node/types"
     8  	"github.com/status-im/status-go/params"
     9  	"github.com/status-im/status-go/rpc"
    10  	"github.com/status-im/status-go/services/ext"
    11  )
    12  
    13  type Service struct {
    14  	*ext.Service
    15  	w types.Waku
    16  }
    17  
    18  func New(config params.NodeConfig, n types.Node, rpcClient *rpc.Client, handler ext.EnvelopeEventsHandler, ldb *leveldb.DB) *Service {
    19  	w, err := n.GetWakuV2(nil)
    20  	if err != nil {
    21  		panic(err)
    22  	}
    23  	delay := ext.DefaultRequestsDelay
    24  	if config.ShhextConfig.RequestsDelay != 0 {
    25  		delay = config.ShhextConfig.RequestsDelay
    26  	}
    27  	requestsRegistry := ext.NewRequestsRegistry(delay)
    28  	mailMonitor := ext.NewMailRequestMonitor(w, handler, requestsRegistry)
    29  	return &Service{
    30  		Service: ext.New(config, n, rpcClient, ldb, mailMonitor, w),
    31  		w:       w,
    32  	}
    33  }
    34  
    35  func (s *Service) PublicWakuAPI() types.PublicWakuAPI {
    36  	return s.w.PublicWakuAPI()
    37  }
    38  
    39  // APIs returns a list of new APIs.
    40  func (s *Service) APIs() []gethrpc.API {
    41  	apis := []gethrpc.API{
    42  		{
    43  			Namespace: "wakuext",
    44  			Version:   "1.0",
    45  			Service:   NewPublicAPI(s),
    46  			Public:    false,
    47  		},
    48  	}
    49  	return apis
    50  }