-
Notifications
You must be signed in to change notification settings - Fork 3
/
service_setup.go
55 lines (47 loc) · 1.59 KB
/
service_setup.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
package node
import (
"fmt"
"github.com/PositionExchange/posichain/api/service"
"github.com/PositionExchange/posichain/api/service/blockproposal"
"github.com/PositionExchange/posichain/api/service/consensus"
"github.com/PositionExchange/posichain/api/service/explorer"
)
// RegisterValidatorServices register the validator services.
func (node *Node) RegisterValidatorServices() {
// Register consensus service.
node.serviceManager.Register(
service.Consensus,
consensus.New(node.BlockChannel, node.Consensus, node.startConsensus),
)
// Register new block service.
node.serviceManager.Register(
service.BlockProposal,
blockproposal.New(node.Consensus.ReadySignal, node.Consensus.CommitSigChannel, node.WaitForConsensusReadyV2),
)
}
// RegisterExplorerServices register the explorer services
func (node *Node) RegisterExplorerServices() {
// Register explorer service.
node.serviceManager.Register(
service.SupportExplorer, explorer.New(node.HarmonyConfig, &node.SelfPeer, node.Blockchain(), node),
)
}
// RegisterService register a service to the node service manager
func (node *Node) RegisterService(st service.Type, s service.Service) {
node.serviceManager.Register(st, s)
}
// StartServices runs registered services.
func (node *Node) StartServices() error {
return node.serviceManager.StartServices()
}
// StopServices runs registered services.
func (node *Node) StopServices() error {
return node.serviceManager.StopServices()
}
func (node *Node) networkInfoDHTPath() string {
return fmt.Sprintf(".dht-%s-%s-c%s",
node.SelfPeer.IP,
node.SelfPeer.Port,
node.chainConfig.ChainID,
)
}