MCPcopy Create free account
hub / github.com/CPChain/chain / removeTx

Method removeTx

core/tx_pool.go:995–1034  ·  view source on GitHub ↗

removeTx removes a single transaction from the queue, moving all subsequent transactions back to the future queue.

(hash common.Hash, outofbound bool)

Source from the content-addressed store, hash-verified

993// removeTx removes a single transaction from the queue, moving all subsequent
994// transactions back to the future queue.
995func (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

Callers 5

loopMethod · 0.95
SetGasPriceMethod · 0.95
addMethod · 0.95
promoteExecutablesMethod · 0.95
TestTransactionChainForkFunction · 0.80

Calls 14

getPendingTxListMethod · 0.95
deletePendingTxListMethod · 0.95
enqueueTxMethod · 0.95
getQueueTxListMethod · 0.95
deleteQueueTxListMethod · 0.95
RemovedMethod · 0.80
GetMethod · 0.65
SenderMethod · 0.65
EmptyMethod · 0.65
HashMethod · 0.65
NonceMethod · 0.65
GetNonceMethod · 0.65

Tested by 1

TestTransactionChainForkFunction · 0.64