Skip to content

Commit 62d2148

Browse files
authored
Merge pull request #2347 from CortexFoundation/dev
define BatchSize as a constant
2 parents 95e8aa0 + 0fea9a2 commit 62d2148

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

ctxc/fetcher/tx_fetcher.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const (
6262
// txGatherSlack is the interval used to collate almost-expired announces
6363
// with network fetches.
6464
txGatherSlack = 100 * time.Millisecond
65+
66+
// addTxsBatchSize it the max number of transactions to add in a single batch from a peer.
67+
addTxsBatchSize = 128
6568
)
6669

6770
var (
@@ -311,8 +314,8 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
311314
added = make([]common.Hash, 0, len(txs))
312315
)
313316
// proceed in batches
314-
for i := 0; i < len(txs); i += 128 {
315-
end := i + 128
317+
for i := 0; i < len(txs); i += addTxsBatchSize {
318+
end := i + addTxsBatchSize
316319
if end > len(txs) {
317320
end = len(txs)
318321
}
@@ -349,7 +352,7 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
349352
otherRejectMeter.Mark(otherreject)
350353

351354
// If 'other reject' is >25% of the deliveries in any batch, sleep a bit.
352-
if otherreject > 128/4 {
355+
if otherreject > addTxsBatchSize/4 {
353356
time.Sleep(200 * time.Millisecond)
354357
log.Trace("Peer delivering stale transactions", "peer", peer, "rejected", otherreject)
355358
}

0 commit comments

Comments
 (0)