Skip to content

Commit 4b656ef

Browse files
committed
extra check
1 parent df76d7a commit 4b656ef

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

txcache/selection.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ func selectTransactionsFromBunches(session SelectionSession, bunches []bunchOfTr
4545
accumulatedGas := uint64(0)
4646
selectionLoopStartTime := time.Now()
4747

48+
var processedTxs int
49+
4850
// Select transactions (sorted).
4951
for transactionsHeap.Len() > 0 {
52+
processedTxs++
53+
5054
// Always pick the best transaction.
5155
item := heap.Pop(transactionsHeap).(*transactionsHeapItem)
5256
gasLimit := item.currentTransaction.Tx.GetGasLimit()
@@ -57,7 +61,7 @@ func selectTransactionsFromBunches(session SelectionSession, bunches []bunchOfTr
5761
if len(selectedTransactions) >= maxNum {
5862
break
5963
}
60-
if len(selectedTransactions)%selectionLoopDurationCheckInterval == 0 {
64+
if processedTxs%selectionLoopDurationCheckInterval == 0 {
6165
if time.Since(selectionLoopStartTime) > selectionLoopMaximumDuration {
6266
logSelect.Debug("TxCache.selectTransactionsFromBunches, selection loop timeout", "duration", time.Since(selectionLoopStartTime))
6367
break

0 commit comments

Comments
 (0)