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

Method enqueueTx

core/tx_pool.go:802–828  ·  view source on GitHub ↗

enqueueTx inserts a new transaction into the non-executable transaction queue. Note, this method assumes the pool lock is held!

(hash common.Hash, tx *types.Transaction)

Source from the content-addressed store, hash-verified

800//
801// Note, this method assumes the pool lock is held!
802func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction) (bool, error) {
803 // Try to insert the transaction into the future queue
804 from, _ := types.Sender(pool.signer, tx) // already validated
805 if pool.getQueueTxList(from) == nil {
806 ok := pool.setQueueTxList(from, newTxList(false))
807 if !ok {
808 return false, ErrExceedQueueMapSize
809 }
810 }
811 inserted, old := pool.getQueueTxList(from).Add(tx, pool.config.PriceBump)
812 if !inserted {
813 // An older transaction was better, discard this
814 queuedDiscardCounter.Inc(1)
815 return false, ErrReplaceUnderpriced
816 }
817 // Discard any previous transaction and mark this
818 if old != nil {
819 pool.all.Remove(old.Hash())
820 pool.priced.Removed()
821 queuedReplaceCounter.Inc(1)
822 }
823 if pool.all.Get(hash) == nil {
824 pool.all.Add(tx)
825 pool.priced.Put(tx)
826 }
827 return old != nil, nil
828}
829
830// journalTx adds the specified transaction to the local disk journal if it is
831// deemed to have been sent from a local account.

Callers 6

addMethod · 0.95
removeTxMethod · 0.95
demoteUnexecutablesMethod · 0.95
TestTransactionQueueFunction · 0.80
TestTransactionDroppingFunction · 0.80
benchmarkFuturePromotionFunction · 0.80

Calls 10

getQueueTxListMethod · 0.95
setQueueTxListMethod · 0.95
newTxListFunction · 0.85
RemovedMethod · 0.80
SenderMethod · 0.65
AddMethod · 0.65
HashMethod · 0.65
GetMethod · 0.65
PutMethod · 0.65
RemoveMethod · 0.45

Tested by 3

TestTransactionQueueFunction · 0.64
TestTransactionDroppingFunction · 0.64
benchmarkFuturePromotionFunction · 0.64