removeTx removes a single transaction from the queue, moving all subsequent transactions back to the future queue.
(hash common.Hash, outofbound bool)
| 993 | // removeTx removes a single transaction from the queue, moving all subsequent |
| 994 | // transactions back to the future queue. |
| 995 | func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) { |
| 996 | // Fetch the transaction we wish to delete |
| 997 | tx := pool.all.Get(hash) |
| 998 | if tx == nil { |
| 999 | return |
| 1000 | } |
| 1001 | addr, _ := types.Sender(pool.signer, tx) // already validated during insertion |
| 1002 | |
| 1003 | // Remove it from the list of known transactions |
| 1004 | pool.all.Remove(hash) |
| 1005 | if outofbound { |
| 1006 | pool.priced.Removed() |
| 1007 | } |
| 1008 | // Remove the transaction from the pending lists and reset the account nonce |
| 1009 | if pending := pool.getPendingTxList(addr); pending != nil { |
| 1010 | if removed, invalids := pending.Remove(tx); removed { |
| 1011 | // If no more pending transactions are left, remove the list |
| 1012 | if pending.Empty() { |
| 1013 | pool.deletePendingTxList(addr) |
| 1014 | delete(pool.beats, addr) |
| 1015 | } |
| 1016 | // Postpone any invalidated transactions |
| 1017 | for _, tx := range invalids { |
| 1018 | pool.enqueueTx(tx.Hash(), tx) |
| 1019 | } |
| 1020 | // Update the account nonce if needed |
| 1021 | if nonce := tx.Nonce(); pool.pendingState.GetNonce(addr) > nonce { |
| 1022 | pool.pendingState.SetNonce(addr, nonce) |
| 1023 | } |
| 1024 | return |
| 1025 | } |
| 1026 | } |
| 1027 | // Transaction is in the future queue |
| 1028 | if future := pool.getQueueTxList(addr); future != nil { |
| 1029 | future.Remove(tx) |
| 1030 | if future.Empty() { |
| 1031 | pool.deleteQueueTxList(addr) |
| 1032 | } |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | // promoteExecutables moves transactions that have become processable from the |
| 1037 | // future queue to the set of pending transactions. During this process, all |