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)
| 800 | // |
| 801 | // Note, this method assumes the pool lock is held! |
| 802 | func (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. |