Skip to content

Commit 3271a5a

Browse files
holimankaralabe
authored andcommitted
miner: don't update pending state when no transactions are added (#19734)
* miner: don't update pending state when no transactions are added * miner: avoid transaction processing when pending block is already full
1 parent 2b303e7 commit 3271a5a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎miner/worker.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ func (w *worker) mainLoop() {
453453
// already included in the current mining block. These transactions will
454454
// be automatically eliminated.
455455
if !w.isRunning() && w.current != nil {
456+
// If block is already full, abort
457+
if gp := w.current.gasPool; gp != nil && gp.Gas() < params.TxGas {
458+
continue
459+
}
456460
w.mu.RLock()
457461
coinbase := w.coinbase
458462
w.mu.RUnlock()
@@ -463,8 +467,13 @@ func (w *worker) mainLoop() {
463467
txs[acc] = append(txs[acc], tx)
464468
}
465469
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs)
470+
tcount := w.current.tcount
466471
w.commitTransactions(txset, coinbase, nil)
467-
w.updateSnapshot()
472+
// Only update the snapshot if any new transactons were added
473+
// to the pending block
474+
if tcount != w.current.tcount {
475+
w.updateSnapshot()
476+
}
468477
} else {
469478
// If clique is running in dev mode(period is 0), disable
470479
// advance sealing here.

0 commit comments

Comments
 (0)