Backup Node

pull/555/head
ak 6 years ago
parent 644a37f2c7
commit 12e4f13955
  1. 3
      internal/configs/node/config.go
  2. 11
      node/service_setup.go

@ -27,6 +27,7 @@ const (
NewNode NewNode
ClientNode ClientNode
WalletNode WalletNode
BackupNode
) )
func (role Role) String() string { func (role Role) String() string {
@ -47,6 +48,8 @@ func (role Role) String() string {
return "ClientNode" return "ClientNode"
case WalletNode: case WalletNode:
return "WalletNode" return "WalletNode"
case BackupNode:
return "BackupNode"
} }
return "Unknown" return "Unknown"
} }

@ -105,6 +105,15 @@ func (node *Node) setupForWalletNode() {
node.serviceManager.RegisterService(service.NetworkInfo, networkinfo.New(node.host, p2p.GroupIDBeacon, chanPeer, nil)) node.serviceManager.RegisterService(service.NetworkInfo, networkinfo.New(node.host, p2p.GroupIDBeacon, chanPeer, nil))
} }
func (node *Node) setupForBackupNode() {
nodeConfig, chanPeer := node.initNodeConfiguration()
// Register peer discovery service.
node.serviceManager.RegisterService(service.PeerDiscovery, discovery.New(node.host, nodeConfig, chanPeer, node.AddBeaconPeer))
// Register networkinfo service. "0" is the beacon shard ID
node.serviceManager.RegisterService(service.NetworkInfo, networkinfo.New(node.host, p2p.GroupIDBeacon, chanPeer, nil))
//TODO: Add Syncing as a service.
}
// ServiceManagerSetup setups service store. // ServiceManagerSetup setups service store.
func (node *Node) ServiceManagerSetup() { func (node *Node) ServiceManagerSetup() {
node.serviceManager = &service.Manager{} node.serviceManager = &service.Manager{}
@ -124,6 +133,8 @@ func (node *Node) ServiceManagerSetup() {
node.setupForClientNode() node.setupForClientNode()
case nodeconfig.WalletNode: case nodeconfig.WalletNode:
node.setupForWalletNode() node.setupForWalletNode()
case nodeconfig.BackupNode:
node.setupForBackupNode()
} }
node.serviceManager.SetupServiceMessageChan(node.serviceMessageChan) node.serviceManager.SetupServiceMessageChan(node.serviceMessageChan)
} }

Loading…
Cancel
Save