github.com/status-im/status-go@v1.1.0/services/stickers/service.go (about) 1 package stickers 2 3 import ( 4 "context" 5 6 "github.com/ethereum/go-ethereum/p2p" 7 ethRpc "github.com/ethereum/go-ethereum/rpc" 8 "github.com/status-im/status-go/account" 9 "github.com/status-im/status-go/ipfs" 10 "github.com/status-im/status-go/multiaccounts/accounts" 11 "github.com/status-im/status-go/params" 12 "github.com/status-im/status-go/rpc" 13 "github.com/status-im/status-go/server" 14 "github.com/status-im/status-go/transactions" 15 ) 16 17 // NewService initializes service instance. 18 func NewService(acc *accounts.Database, rpcClient *rpc.Client, accountsManager *account.GethManager, config *params.NodeConfig, downloader *ipfs.Downloader, httpServer *server.MediaServer, pendingTracker *transactions.PendingTxTracker) *Service { 19 ctx, cancel := context.WithCancel(context.Background()) 20 21 return &Service{ 22 accountsDB: acc, 23 rpcClient: rpcClient, 24 accountsManager: accountsManager, 25 keyStoreDir: config.KeyStoreDir, 26 downloader: downloader, 27 httpServer: httpServer, 28 ctx: ctx, 29 cancel: cancel, 30 api: NewAPI(ctx, acc, rpcClient, accountsManager, pendingTracker, config.KeyStoreDir, downloader, httpServer), 31 } 32 } 33 34 // Service is a browsers service. 35 type Service struct { 36 accountsDB *accounts.Database 37 rpcClient *rpc.Client 38 accountsManager *account.GethManager 39 downloader *ipfs.Downloader 40 keyStoreDir string 41 httpServer *server.MediaServer 42 ctx context.Context 43 cancel context.CancelFunc 44 api *API 45 } 46 47 // Start a service. 48 func (s *Service) Start() error { 49 return nil 50 } 51 52 // Stop a service. 53 func (s *Service) Stop() error { 54 s.cancel() 55 return nil 56 } 57 58 func (s *Service) API() *API { 59 return s.api 60 } 61 62 // APIs returns list of available RPC APIs. 63 func (s *Service) APIs() []ethRpc.API { 64 return []ethRpc.API{ 65 { 66 Namespace: "stickers", 67 Version: "0.1.0", 68 Service: s.api, 69 }, 70 } 71 } 72 73 // Protocols returns list of p2p protocols. 74 func (s *Service) Protocols() []p2p.Protocol { 75 return nil 76 }