From 12e4f13955bced04a0c70721120303f9ebf2b139 Mon Sep 17 00:00:00 2001 From: ak Date: Mon, 11 Mar 2019 18:49:47 -0700 Subject: [PATCH] Backup Node --- internal/configs/node/config.go | 3 +++ node/service_setup.go | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/internal/configs/node/config.go b/internal/configs/node/config.go index d3e77002f..ad13eac6d 100644 --- a/internal/configs/node/config.go +++ b/internal/configs/node/config.go @@ -27,6 +27,7 @@ const ( NewNode ClientNode WalletNode + BackupNode ) func (role Role) String() string { @@ -47,6 +48,8 @@ func (role Role) String() string { return "ClientNode" case WalletNode: return "WalletNode" + case BackupNode: + return "BackupNode" } return "Unknown" } diff --git a/node/service_setup.go b/node/service_setup.go index 4f9367428..6db45d669 100644 --- a/node/service_setup.go +++ b/node/service_setup.go @@ -105,6 +105,15 @@ func (node *Node) setupForWalletNode() { 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. func (node *Node) ServiceManagerSetup() { node.serviceManager = &service.Manager{} @@ -124,6 +133,8 @@ func (node *Node) ServiceManagerSetup() { node.setupForClientNode() case nodeconfig.WalletNode: node.setupForWalletNode() + case nodeconfig.BackupNode: + node.setupForBackupNode() } node.serviceManager.SetupServiceMessageChan(node.serviceMessageChan) }