aboutsummaryrefslogtreecommitdiffstats
path: root/miner/worker.go
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-06-19 19:09:28 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-06-19 19:09:28 +0800
commit3271a5afa0b3a8d65357347db65b45ddb91c5bcd (patch)
tree2ac0600715695138e2ab0b8a5090c2add4764e53 /miner/worker.go
parent2b303e7d625033afafc7ec5a2e73ce08fddd2321 (diff)
downloadgo-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.tar
go-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.tar.gz
go-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.tar.bz2
go-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.tar.lz
go-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.tar.xz
go-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.tar.zst
go-tangerine-3271a5afa0b3a8d65357347db65b45ddb91c5bcd.zip
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
Diffstat (limited to 'miner/worker.go')
-rw-r--r--miner/worker.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/miner/worker.go b/miner/worker.go
index 64ac21ccd..4a9528c39 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -453,6 +453,10 @@ func (w *worker) mainLoop() {
// already included in the current mining block. These transactions will
// be automatically eliminated.
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()
coinbase := w.coinbase
w.mu.RUnlock()
@@ -463,8 +467,13 @@ func (w *worker) mainLoop() {
txs[acc] = append(txs[acc], tx)
}
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs)
+ tcount := w.current.tcount
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 {
// If clique is running in dev mode(period is 0), disable
// advance sealing here.