Skip to content

Commit

Permalink
only broadcast vote, timeout and syncinfo if the peer do not have it (e…
Browse files Browse the repository at this point in the history
wjrjerome authored Feb 11, 2022

Verified

This commit was signed with the committer’s verified signature.
hediet Henning Dieterichs
1 parent da336f5 commit 76724b0
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions eth/handler.go
Original file line number Diff line number Diff line change
@@ -906,32 +906,48 @@ func (pm *ProtocolManager) BroadcastTx(hash common.Hash, tx *types.Transaction)
func (pm *ProtocolManager) BroadcastVote(vote *utils.Vote) {
hash := vote.Hash()
peers := pm.peers.PeersWithoutVote(hash)
for _, peer := range peers {
peer.SendVote(vote)
if len(peers) > 0 {
for _, peer := range peers {
err := peer.SendVote(vote)
if err != nil {
log.Error("[BroadcastVote] Fail to broadcast vote message", "NumberOfPeers", len(peers), "peerId", peer.id, "vote", vote, "Error", err)
}
}
log.Info("Propagated Vote", "vote hash", vote.Hash(), "voted block hash", vote.ProposedBlockInfo.Hash.Hex(), "number", vote.ProposedBlockInfo.Number, "round", vote.ProposedBlockInfo.Round, "recipients", len(peers))
}
log.Info("Propagated Vote", "vote hash", vote.Hash(), "voted block hash", vote.ProposedBlockInfo.Hash.Hex(), "number", vote.ProposedBlockInfo.Number, "round", vote.ProposedBlockInfo.Round, "recipients", len(peers))
}

// BroadcastTimeout will propagate a Timeout to all peers which are not known to
// already have the given timeout.
func (pm *ProtocolManager) BroadcastTimeout(timeout *utils.Timeout) {
hash := timeout.Hash()
peers := pm.peers.PeersWithoutTimeout(hash)
for _, peer := range peers {
peer.SendTimeout(timeout)
if len(peers) > 0 {
for _, peer := range peers {
err := peer.SendTimeout(timeout)
if err != nil {
log.Error("[BroadcastTimeout] Fail to broadcast timeout message", "NumberOfPeers", len(peers), "peerId", peer.id, "timeout", timeout, "Error", err)
}
}
log.Trace("Propagated Timeout", "hash", hash, "recipients", len(peers))
}
log.Trace("Propagated Timeout", "hash", hash, "recipients", len(peers))
}

// BroadcastSyncInfo will propagate a SyncInfo to all peers which are not known to
// already have the given SyncInfo.
func (pm *ProtocolManager) BroadcastSyncInfo(syncInfo *utils.SyncInfo) {
hash := syncInfo.Hash()
peers := pm.peers.PeersWithoutSyncInfo(hash)
for _, peer := range peers {
peer.SendSyncInfo(syncInfo)
if len(peers) > 0 {
for _, peer := range peers {
err := peer.SendSyncInfo(syncInfo)
if err != nil {
log.Error("[BroadcastSyncInfo] Fail to broadcast syncInfo message", "NumberOfPeers", len(peers), "peerId", peer.id, "syncInfo", syncInfo, "Error", err)
}
}
log.Trace("Propagated SyncInfo", "hash", hash, "recipients", len(peers))
}
log.Trace("Propagated SyncInfo", "hash", hash, "recipients", len(peers))

}

// OrderBroadcastTx will propagate a transaction to all peers which are not known to

0 comments on commit 76724b0

Please sign in to comment.