Skip to content

Commit

Permalink
eth: simplify peer counting logic (#29420)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiweixie authored Apr 3, 2024
1 parent dfb3d46 commit 7bb3fb1
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
largeTxs int // Number of large transactions to announce only

directCount int // Number of transactions sent directly to peers (duplicates included)
directPeers int // Number of peers that were sent transactions directly
annCount int // Number of transactions announced across all peers (duplicates included)
annPeers int // Number of peers announced about transactions

txset = make(map[*ethPeer][]common.Hash) // Set peer->hash to transfer directly
annos = make(map[*ethPeer][]common.Hash) // Set peer->hash to announce
Expand Down Expand Up @@ -525,17 +523,15 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
}
}
for peer, hashes := range txset {
directPeers++
directCount += len(hashes)
peer.AsyncSendTransactions(hashes)
}
for peer, hashes := range annos {
annPeers++
annCount += len(hashes)
peer.AsyncSendPooledTransactionHashes(hashes)
}
log.Debug("Distributed transactions", "plaintxs", len(txs)-blobTxs-largeTxs, "blobtxs", blobTxs, "largetxs", largeTxs,
"bcastpeers", directPeers, "bcastcount", directCount, "annpeers", annPeers, "anncount", annCount)
"bcastpeers", len(txset), "bcastcount", directCount, "annpeers", len(annos), "anncount", annCount)
}

// txBroadcastLoop announces new transactions to connected peers.
Expand Down

0 comments on commit 7bb3fb1

Please sign in to comment.