diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-09-05 03:35:00 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-09-05 18:34:41 +0800 |
commit | da7d57e07c04dcbb7cc20b35f6606ef3f4c400e3 (patch) | |
tree | 01b0266516f76b69ab7d93b0c78e396b3e712600 /miner | |
parent | e7408b5552002df7c3ba6a2351f14c533dfc5a36 (diff) | |
download | dexon-da7d57e07c04dcbb7cc20b35f6606ef3f4c400e3.tar.gz dexon-da7d57e07c04dcbb7cc20b35f6606ef3f4c400e3.tar.zst dexon-da7d57e07c04dcbb7cc20b35f6606ef3f4c400e3.zip |
core: make txpool operate on immutable state
Diffstat (limited to 'miner')
-rw-r--r-- | miner/worker.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/miner/worker.go b/miner/worker.go index 24e03be60..5bac5d6e8 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -71,7 +71,6 @@ type Work struct { family *set.Set // family set (used for checking uncle invalidity) uncles *set.Set // uncle set tcount int // tx count in cycle - failedTxs types.Transactions Block *types.Block // the new block @@ -477,8 +476,6 @@ func (self *worker) commitNewWork() { txs := types.NewTransactionsByPriceAndNonce(pending) work.commitTransactions(self.mux, txs, self.chain, self.coinbase) - self.eth.TxPool().RemoveBatch(work.failedTxs) - // compute uncles for the new block. var ( uncles []*types.Header @@ -563,6 +560,16 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB log.Trace("Gas limit exceeded for current block", "sender", from) txs.Pop() + case core.ErrNonceTooLow: + // New head notification data race between the transaction pool and miner, shift + log.Trace("Skipping transaction with low nonce", "sender", from, "nonce", tx.Nonce()) + txs.Shift() + + case core.ErrNonceTooHigh: + // Reorg notification data race between the transaction pool and miner, skip account = + log.Trace("Skipping account with hight nonce", "sender", from, "nonce", tx.Nonce()) + txs.Pop() + case nil: // Everything ok, collect the logs and shift in the next transaction from the same account coalescedLogs = append(coalescedLogs, logs...) @@ -570,10 +577,10 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB txs.Shift() default: - // Pop the current failed transaction without shifting in the next from the account - log.Trace("Transaction failed, will be removed", "hash", tx.Hash(), "err", err) - env.failedTxs = append(env.failedTxs, tx) - txs.Pop() + // Strange error, discard the transaction and get the next in line (note, the + // nonce-too-high clause will prevent us from executing in vain). + log.Debug("Transaction failed, account skipped", "hash", tx.Hash(), "err", err) + txs.Shift() } } |