From 0dbb3b160164cbc352892cc49a19ee7d3428bb96 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 4 Oct 2021 16:10:51 +0200 Subject: [PATCH] eth/protocols/eth: replace array with counter in txn broadcaster (#23656) --- eth/protocols/eth/broadcast.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eth/protocols/eth/broadcast.go b/eth/protocols/eth/broadcast.go index 328396d510..614e6361c6 100644 --- a/eth/protocols/eth/broadcast.go +++ b/eth/protocols/eth/broadcast.go @@ -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 {