forked from cerc-io/plugeth
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
This commit is contained in:
parent
2b303e7d62
commit
3271a5afa0
@ -453,6 +453,10 @@ func (w *worker) mainLoop() {
|
|||||||
// already included in the current mining block. These transactions will
|
// already included in the current mining block. These transactions will
|
||||||
// be automatically eliminated.
|
// be automatically eliminated.
|
||||||
if !w.isRunning() && w.current != nil {
|
if !w.isRunning() && w.current != nil {
|
||||||
|
// If block is already full, abort
|
||||||
|
if gp := w.current.gasPool; gp != nil && gp.Gas() < params.TxGas {
|
||||||
|
continue
|
||||||
|
}
|
||||||
w.mu.RLock()
|
w.mu.RLock()
|
||||||
coinbase := w.coinbase
|
coinbase := w.coinbase
|
||||||
w.mu.RUnlock()
|
w.mu.RUnlock()
|
||||||
@ -463,8 +467,13 @@ func (w *worker) mainLoop() {
|
|||||||
txs[acc] = append(txs[acc], tx)
|
txs[acc] = append(txs[acc], tx)
|
||||||
}
|
}
|
||||||
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs)
|
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs)
|
||||||
|
tcount := w.current.tcount
|
||||||
w.commitTransactions(txset, coinbase, nil)
|
w.commitTransactions(txset, coinbase, nil)
|
||||||
w.updateSnapshot()
|
// Only update the snapshot if any new transactons were added
|
||||||
|
// to the pending block
|
||||||
|
if tcount != w.current.tcount {
|
||||||
|
w.updateSnapshot()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If clique is running in dev mode(period is 0), disable
|
// If clique is running in dev mode(period is 0), disable
|
||||||
// advance sealing here.
|
// advance sealing here.
|
||||||
|
Loading…
Reference in New Issue
Block a user