github.com/status-im/status-go@v1.1.0/services/subscriptions/service.go (about) 1 package subscriptions 2 3 import ( 4 gethnode "github.com/ethereum/go-ethereum/node" 5 "github.com/ethereum/go-ethereum/p2p" 6 gethrpc "github.com/ethereum/go-ethereum/rpc" 7 8 "github.com/status-im/status-go/rpc" 9 ) 10 11 // Make sure that Service implements gethnode.Lifecycle interface. 12 var _ gethnode.Lifecycle = (*Service)(nil) 13 14 // Service represents our own implementation of personal sign operations. 15 type Service struct { 16 api *API 17 } 18 19 // New returns a new Service. 20 func New(rpcPrivateClientFunc func() *rpc.Client) *Service { 21 return &Service{ 22 api: NewPublicAPI(rpcPrivateClientFunc), 23 } 24 } 25 26 // Protocols returns a new protocols list. In this case, there are none. 27 func (s *Service) Protocols() []p2p.Protocol { 28 return []p2p.Protocol{} 29 } 30 31 // APIs returns a list of new APIs. 32 func (s *Service) APIs() []gethrpc.API { 33 return []gethrpc.API{ 34 { 35 Namespace: "eth", 36 Version: "1.0", 37 Service: s.api, 38 Public: true, 39 }, 40 } 41 } 42 43 // Start is run when a service is started. 44 func (s *Service) Start() error { 45 return nil 46 } 47 48 // Stop is run when a service is stopped. 49 func (s *Service) Stop() error { 50 return s.api.activeSubscriptions.removeAll() 51 }