|
|
@ -37,6 +37,9 @@ func SendMessage(peer Peer, msg []byte) { |
|
|
|
|
|
|
|
|
|
|
|
// BroadcastMessage sends the message to a list of peers
|
|
|
|
// BroadcastMessage sends the message to a list of peers
|
|
|
|
func BroadcastMessage(peers []Peer, msg []byte) { |
|
|
|
func BroadcastMessage(peers []Peer, msg []byte) { |
|
|
|
|
|
|
|
if len(peers) == 0 { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
// Construct broadcast p2p message
|
|
|
|
// Construct broadcast p2p message
|
|
|
|
content := ConstructP2pMessage(byte(17), msg) |
|
|
|
content := ConstructP2pMessage(byte(17), msg) |
|
|
|
|
|
|
|
|
|
|
@ -77,10 +80,8 @@ func BroadcastMessageFromLeader(peers []Peer, msg []byte) { |
|
|
|
// BroadcastMessage sends the message to a list of peers from a validator.
|
|
|
|
// BroadcastMessage sends the message to a list of peers from a validator.
|
|
|
|
func BroadcastMessageFromValidator(selfPeer Peer, peers []Peer, msg []byte) { |
|
|
|
func BroadcastMessageFromValidator(selfPeer Peer, peers []Peer, msg []byte) { |
|
|
|
peers = SelectMyPeers(peers, selfPeer.ValidatorID*MAX_BROADCAST+1, (selfPeer.ValidatorID+1)*MAX_BROADCAST) |
|
|
|
peers = SelectMyPeers(peers, selfPeer.ValidatorID*MAX_BROADCAST+1, (selfPeer.ValidatorID+1)*MAX_BROADCAST) |
|
|
|
if len(peers) > 0 { |
|
|
|
BroadcastMessage(peers, msg) |
|
|
|
BroadcastMessage(peers, msg) |
|
|
|
log.Info("Done sending from validator") |
|
|
|
log.Info("Done sending from validator") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]
|
|
|
|
// ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]
|
|
|
|