Remove any invalid transactions after block processing
This commit is contained in:
parent
ff2cf2dacd
commit
98a631b556
|
@ -199,6 +199,8 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
sm.Ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val})
|
sm.Ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val})
|
||||||
|
|
||||||
|
sm.Ethereum.TxPool().RemoveInvalid(sm.procState)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("total diff failed")
|
fmt.Println("total diff failed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,9 +210,9 @@ func (pool *TxPool) CurrentTransactions() []*Transaction {
|
||||||
txList := make([]*Transaction, pool.pool.Len())
|
txList := make([]*Transaction, pool.pool.Len())
|
||||||
i := 0
|
i := 0
|
||||||
for e := pool.pool.Front(); e != nil; e = e.Next() {
|
for e := pool.pool.Front(); e != nil; e = e.Next() {
|
||||||
if tx, ok := e.Value.(*Transaction); ok {
|
tx := e.Value.(*Transaction)
|
||||||
txList[i] = tx
|
|
||||||
}
|
txList[i] = tx
|
||||||
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,17 @@ func (pool *TxPool) CurrentTransactions() []*Transaction {
|
||||||
return txList
|
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 {
|
func (pool *TxPool) Flush() []*Transaction {
|
||||||
txList := pool.CurrentTransactions()
|
txList := pool.CurrentTransactions()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue