diff --git a/p2p/peer.go b/p2p/peer.go index eec16064d..de3533514 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -37,6 +37,9 @@ func SendMessage(peer Peer, msg []byte) { // BroadcastMessage sends the message to a list of peers func BroadcastMessage(peers []Peer, msg []byte) { + if len(peers) == 0 { + return + } // Construct broadcast p2p message 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. func BroadcastMessageFromValidator(selfPeer Peer, peers []Peer, msg []byte) { peers = SelectMyPeers(peers, selfPeer.ValidatorID*MAX_BROADCAST+1, (selfPeer.ValidatorID+1)*MAX_BROADCAST) - if len(peers) > 0 { - BroadcastMessage(peers, msg) - log.Info("Done sending from validator") - } + BroadcastMessage(peers, msg) + log.Info("Done sending from validator") } // ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]