Skip to content

Commit

Permalink
eth/protocols/eth: replace array with counter in txn broadcaster (eth…
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt authored and zzyalbert committed Nov 26, 2021
1 parent 29bc434 commit 6db82ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions eth/protocols/eth/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ func (p *Peer) broadcastTransactions() {
if done == nil && len(queue) > 0 {
// Pile transaction until we reach our allowed network limit
var (
hashes []common.Hash
txs []*types.Transaction
size common.StorageSize
hashesCount uint64
txs []*types.Transaction
size common.StorageSize
)
for i := 0; i < len(queue) && size < maxTxPacketSize; i++ {
if tx := p.txpool.Get(queue[i]); tx != nil {
txs = append(txs, tx)
size += tx.Size()
}
hashes = append(hashes, queue[i])
hashesCount++
}
queue = queue[:copy(queue, queue[len(hashes):])]
queue = queue[:copy(queue, queue[hashesCount:])]

// If there's anything available to transfer, fire up an async writer
if len(txs) > 0 {
Expand Down

0 comments on commit 6db82ed

Please sign in to comment.