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

Method addTx

core/tx_pool.go:913–932  ·  view source on GitHub ↗

addTx enqueues a single transaction into the pool if it is valid.

(tx *types.Transaction, local bool)

Source from the content-addressed store, hash-verified

911
912// addTx enqueues a single transaction into the pool if it is valid.
913func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
914 pool.mu.Lock()
915 defer pool.mu.Unlock()
916
917 // Try to inject the transaction and update any state
918 start := time.Now()
919 replace, err := pool.add(tx, local)
920 log.Debug("add tx to pool", "tx", tx.Hash(), "elapsed", common.PrettyDuration(time.Since(start)))
921 if err != nil {
922 return err
923 }
924 // If we added a new transaction, run promotion checks and return
925 if !replace {
926 start := time.Now()
927 from, _ := types.Sender(pool.signer, tx) // already validated
928 pool.promoteExecutables([]common.Address{from})
929 log.Debug("promoteExecutables", "elapsed", common.PrettyDuration(time.Since(start)))
930 }
931 return nil
932}
933
934// addTxs attempts to queue a batch of transactions if they are valid.
935func (pool *TxPool) addTxs(txs []*types.Transaction, local bool) []error {

Callers 2

AddLocalMethod · 0.95
AddRemoteMethod · 0.95

Calls 8

addMethod · 0.95
promoteExecutablesMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
DebugMethod · 0.80
NowMethod · 0.65
HashMethod · 0.65
SenderMethod · 0.65

Tested by

no test coverage detected