diff --git a/benchmark.go b/benchmark.go index b1c43e396..5b698c651 100644 --- a/benchmark.go +++ b/benchmark.go @@ -230,8 +230,6 @@ func main() { } } - go currentNode.StartServer(*port) - go currentNode.StartHelpSyncing() - // Keep waiting. - <-make(chan struct{}) + go currentNode.SupportSyncing() + currentNode.StartServer(*port) } diff --git a/node/node.go b/node/node.go index 555f786b0..f420ab9a3 100644 --- a/node/node.go +++ b/node/node.go @@ -50,7 +50,7 @@ const ( TimeToSleepForSyncing = time.Second * 30 ) -// NetworkNode is TODO(leo) +// NetworkNode ... type NetworkNode struct { SelfPeer p2p.Peer IDCPeer p2p.Peer @@ -351,17 +351,10 @@ func (node *Node) JoinShard(leader p2p.Peer) { } } -// StartHelpSyncing keeps sleeping until it's doing consensus or it's a leader. -func (node *Node) StartHelpSyncing() { - for { - time.Sleep(TimeToSleepForSyncing) - // - if node.State == NodeDoingConsensus || node.State == NodeLeader { - node.InitSyncingServer() - node.StartHelpSyncing() - break - } - } +// SupportSyncing keeps sleeping until it's doing consensus or it's a leader. +func (node *Node) SupportSyncing() { + node.InitSyncingServer() + node.StartSyncingServer() } // InitSyncingServer starts downloader server. @@ -372,7 +365,7 @@ func (node *Node) InitSyncingServer() { // StartSyncingServer starts syncing server. func (node *Node) StartSyncingServer() { // Handles returned grpcServer?? - node.downloaderServer.Start("localhost", downloader.DefaultDownloadPort) + node.downloaderServer.Start(node.SelfPeer.Ip, downloader.DefaultDownloadPort) } // CalculateResponse implements DownloadInterface on Node object.