diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-14 22:29:34 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-14 22:29:34 +0800 |
commit | 98a631b5563b8a87c3fc83f14256087251926a61 (patch) | |
tree | 2dbada4e80dd3e70a99fe692c7454c7de9c5a99e /ethchain/transaction_pool.go | |
parent | ff2cf2dacd3470e7c2800e2f3644cfc05dfa6c4e (diff) | |
download | dexon-98a631b5563b8a87c3fc83f14256087251926a61.tar dexon-98a631b5563b8a87c3fc83f14256087251926a61.tar.gz dexon-98a631b5563b8a87c3fc83f14256087251926a61.tar.bz2 dexon-98a631b5563b8a87c3fc83f14256087251926a61.tar.lz dexon-98a631b5563b8a87c3fc83f14256087251926a61.tar.xz dexon-98a631b5563b8a87c3fc83f14256087251926a61.tar.zst dexon-98a631b5563b8a87c3fc83f14256087251926a61.zip |
Remove any invalid transactions after block processing
Diffstat (limited to 'ethchain/transaction_pool.go')
-rw-r--r-- | ethchain/transaction_pool.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go index 56deae0c6..6c0282dc6 100644 --- a/ethchain/transaction_pool.go +++ b/ethchain/transaction_pool.go @@ -210,9 +210,9 @@ func (pool *TxPool) CurrentTransactions() []*Transaction { txList := make([]*Transaction, pool.pool.Len()) i := 0 for e := pool.pool.Front(); e != nil; e = e.Next() { - if tx, ok := e.Value.(*Transaction); ok { - txList[i] = tx - } + tx := e.Value.(*Transaction) + + txList[i] = tx i++ } @@ -220,6 +220,17 @@ func (pool *TxPool) CurrentTransactions() []*Transaction { return txList } +func (pool *TxPool) RemoveInvalid(state *State) { + for e := pool.pool.Front(); e != nil; e = e.Next() { + tx := e.Value.(*Transaction) + sender := state.GetAccount(tx.Sender()) + err := pool.ValidateTransaction(tx) + if err != nil || sender.Nonce != tx.Nonce { + pool.pool.Remove(e) + } + } +} + func (pool *TxPool) Flush() []*Transaction { txList := pool.CurrentTransactions() |