status-go/services/accounts/service.go

63 lines
1.5 KiB
Go
Raw Normal View History

package accounts
import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
2020-01-02 09:10:19 +00:00
"github.com/status-im/status-go/account"
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/params"
)
// NewService initializes service instance.
func NewService(db *accounts.Database, mdb *multiaccounts.Database, manager *account.GethManager, config *params.NodeConfig, feed *event.Feed) *Service {
return &Service{db, mdb, manager, config, feed}
}
// Service is a browsers service.
type Service struct {
db *accounts.Database
mdb *multiaccounts.Database
manager *account.GethManager
config *params.NodeConfig
feed *event.Feed
}
// Start a service.
func (s *Service) Start() error {
return s.manager.InitKeystore(s.config.KeyStoreDir)
}
// Stop a service.
func (s *Service) Stop() error {
return nil
}
// APIs returns list of available RPC APIs.
func (s *Service) APIs() []rpc.API {
return []rpc.API{
{
Namespace: "settings",
Version: "0.1.0",
Service: NewSettingsAPI(s.db, s.config),
},
{
Namespace: "accounts",
Version: "0.1.0",
Service: NewAccountsAPI(s.manager, s.config, s.db, s.feed),
},
{
Namespace: "multiaccounts",
Version: "0.1.0",
Service: NewMultiAccountsAPI(s.mdb),
},
}
}
// Protocols returns list of p2p protocols.
func (s *Service) Protocols() []p2p.Protocol {
return nil
}