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