-
Notifications
You must be signed in to change notification settings - Fork 244
/
service.go
62 lines (52 loc) · 1.08 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
52
53
54
55
56
57
58
59
60
61
62
package permissions
import (
"sync"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
)
// NewService initializes service instance.
func NewService() *Service {
return &Service{}
}
type Service struct {
mu sync.Mutex
db *Database
}
// Start a service.
func (s *Service) Start(*p2p.Server) error {
return nil
}
// StartDatabase after dbpath and password will become known.
func (s *Service) StartDatabase(dbpath, password string) (err error) {
s.mu.Lock()
defer s.mu.Unlock()
s.db, err = InitializeDB(dbpath, password)
return err
}
func (s *Service) StopDatabase() error {
s.mu.Lock()
defer s.mu.Unlock()
if s.db != nil {
return s.db.Close()
}
return nil
}
// Stop a service.
func (s *Service) Stop() error {
return s.StopDatabase()
}
// APIs returns list of available RPC APIs.
func (s *Service) APIs() []rpc.API {
return []rpc.API{
{
Namespace: "permissions",
Version: "0.1.0",
Service: NewAPI(s),
Public: true,
},
}
}
// Protocols returns list of p2p protocols.
func (s *Service) Protocols() []p2p.Protocol {
return nil
}