HAR-65: use better broadcast model for ping message

Signed-off-by: Leo Chen <leo@harmony.one>
pull/116/head
Leo Chen 6 years ago
parent 03e7320ca9
commit 7bf3bfcdfc
  1. 4
      node/node_handler.go
  2. 2
      p2p/peer.go

@ -542,9 +542,7 @@ func (node *Node) pingMessageHandler(msgPayload []byte) int {
pong := proto_node.NewPongMessage(peers, node.Consensus.PublicKeys)
buffer := pong.ConstructPongMessage()
for _, p := range peers {
p2p.SendMessage(p, buffer)
}
p2p.BroadcastMessageFromLeader(peers, buffer)
return len(peers)
}

@ -80,14 +80,12 @@ func BroadcastMessageFromLeader(peers []Peer, msg []byte) {
// TODO(minhdoan): Enable back for multicast.
peers = SelectMyPeers(peers, 1, MaxBroadCast)
BroadcastMessage(peers, msg)
log.Info("Done sending from leader")
}
// BroadcastMessageFromValidator sends the message to a list of peers from a validator.
func BroadcastMessageFromValidator(selfPeer Peer, peers []Peer, msg []byte) {
peers = SelectMyPeers(peers, selfPeer.ValidatorID*MaxBroadCast+1, (selfPeer.ValidatorID+1)*MaxBroadCast)
BroadcastMessage(peers, msg)
log.Info("Done sending from validator")
}
// ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]

Loading…
Cancel
Save