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

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