Skip to content

Commit

Permalink
Bugfix: attempting to broadcast to more peers than we have
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 authored and alanorwick committed Mar 22, 2023
1 parent 001f811 commit e0f0d12
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,13 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
numDirect := int(math.Sqrt(float64(len(peers))))
subset := peers[:numDirect]
if len(subset) < minPeerSendTx {
// If our subset is less than the minimum, send to the minimum
subset = peers[:minPeerSendTx+1] // The high bound is exclusive
// If we have less peers than the minimum, send to all peers
if len(peers) < minPeerSendTx {
subset = peers
} else {
// If our subset is less than the minimum, send to the minimum
subset = peers[:minPeerSendTx] // The high bound is exclusive
}
}
for _, peer := range subset {
txset[peer] = append(txset[peer], tx.Hash())
Expand Down

0 comments on commit e0f0d12

Please sign in to comment.