Merge pull request #593 from LeoHChen/skip_ping_for_validator

Skip ping for validator
pull/607/head
Leo Chen 6 years ago committed by GitHub
commit 531a2a7ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      cmd/harmony/main.go
  2. 7
      node/node_handler.go

@ -207,10 +207,13 @@ func setUpConsensusAndNode(nodeConfig *nodeconfig.ConfigType) (*consensus.Consen
if *isBeacon {
if nodeConfig.StringRole == "leader" {
currentNode.NodeConfig.SetRole(nodeconfig.BeaconLeader)
currentNode.NodeConfig.SetIsLeader(true)
} else {
currentNode.NodeConfig.SetRole(nodeconfig.BeaconValidator)
currentNode.NodeConfig.SetIsLeader(false)
}
currentNode.NodeConfig.SetShardGroupID(p2p.GroupIDBeacon)
currentNode.NodeConfig.SetIsBeacon(true)
} else {
currentNode.AddBeaconChainDatabase(nodeConfig.BeaconDB)
@ -218,10 +221,13 @@ func setUpConsensusAndNode(nodeConfig *nodeconfig.ConfigType) (*consensus.Consen
currentNode.NodeConfig.SetRole(nodeconfig.NewNode)
} else if nodeConfig.StringRole == "leader" {
currentNode.NodeConfig.SetRole(nodeconfig.ShardLeader)
currentNode.NodeConfig.SetIsLeader(true)
} else {
currentNode.NodeConfig.SetRole(nodeconfig.ShardValidator)
currentNode.NodeConfig.SetIsLeader(false)
}
currentNode.NodeConfig.SetShardGroupID(p2p.GroupIDUnknown)
currentNode.NodeConfig.SetIsBeacon(false)
}
// Add randomness protocol

@ -388,9 +388,10 @@ func (node *Node) pingMessageHandler(msgPayload []byte, sender string) int {
return 0
}
// Add to Node's peer list anyway
utils.GetLogInstance().Info("Add Peer to Node", "Node", node.Consensus.GetNodeID(), "Pear", peer)
node.AddPeers([]*p2p.Peer{peer})
if node.NodeConfig.IsLeader() {
utils.GetLogInstance().Info("Add Peer to Node", "Node", node.Consensus.GetNodeID(), "Pear", peer)
node.AddPeers([]*p2p.Peer{peer})
}
return 1
}

Loading…
Cancel
Save