Documentation
¶
Overview ¶
Package mempooltest provides test helpers for code that uses the mempool package.
Index ¶
- type MockTxMempool
- func (m *MockTxMempool) CheckMempoolAcceptance(tx *btcutil.Tx) (*mempool.MempoolAcceptResult, error)
- func (m *MockTxMempool) CheckSpend(op wire.OutPoint) *btcutil.Tx
- func (m *MockTxMempool) Count() int
- func (m *MockTxMempool) FetchTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error)
- func (m *MockTxMempool) HaveTransaction(hash *chainhash.Hash) bool
- func (m *MockTxMempool) LastUpdated() time.Time
- func (m *MockTxMempool) ProcessTransaction(tx *btcutil.Tx, allowOrphan, rateLimit bool, tag mempool.Tag) ([]*mempool.TxDesc, error)
- func (m *MockTxMempool) RawMempoolVerbose() map[string]...
- func (m *MockTxMempool) RemoveTransaction(tx *btcutil.Tx, removeRedeemers bool)
- func (m *MockTxMempool) TxDescs() []*mempool.TxDesc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockTxMempool ¶
MockTxMempool is a mock implementation of the TxMempool interface.
func (*MockTxMempool) CheckMempoolAcceptance ¶
func (m *MockTxMempool) CheckMempoolAcceptance( tx *btcutil.Tx) (*mempool.MempoolAcceptResult, error)
CheckMempoolAcceptance behaves similarly to bitcoind's `testmempoolaccept` RPC method. It will perform a series of checks to decide whether this transaction can be accepted to the mempool. If not, the specific error is returned and the caller needs to take actions based on it.
func (*MockTxMempool) CheckSpend ¶
func (m *MockTxMempool) CheckSpend(op wire.OutPoint) *btcutil.Tx
CheckSpend checks whether the passed outpoint is already spent by a transaction in the mempool. If that's the case the spending transaction will be returned, if not nil will be returned.
func (*MockTxMempool) Count ¶
func (m *MockTxMempool) Count() int
Count returns the number of transactions in the main pool. It does not include the orphan pool.
func (*MockTxMempool) FetchTransaction ¶
FetchTransaction returns the requested transaction from the transaction pool. This only fetches from the main transaction pool and does not include orphans.
func (*MockTxMempool) HaveTransaction ¶
func (m *MockTxMempool) HaveTransaction(hash *chainhash.Hash) bool
HaveTransaction returns whether or not the passed transaction already exists in the main pool or in the orphan pool.
func (*MockTxMempool) LastUpdated ¶
func (m *MockTxMempool) LastUpdated() time.Time
LastUpdated returns the last time a transaction was added to or removed from the source pool.
func (*MockTxMempool) ProcessTransaction ¶
func (m *MockTxMempool) ProcessTransaction(tx *btcutil.Tx, allowOrphan, rateLimit bool, tag mempool.Tag) ([]*mempool.TxDesc, error)
ProcessTransaction is the main workhorse for handling insertion of new free-standing transactions into the memory pool. It includes functionality such as rejecting duplicate transactions, ensuring transactions follow all rules, orphan transaction handling, and insertion into the memory pool.
func (*MockTxMempool) RawMempoolVerbose ¶
func (m *MockTxMempool) RawMempoolVerbose() map[string]*btcjson. GetRawMempoolVerboseResult
RawMempoolVerbose returns all the entries in the mempool as a fully populated btcjson result.
func (*MockTxMempool) RemoveTransaction ¶
func (m *MockTxMempool) RemoveTransaction(tx *btcutil.Tx, removeRedeemers bool)
RemoveTransaction removes the passed transaction from the mempool. When the removeRedeemers flag is set, any transactions that redeem outputs from the removed transaction will also be removed recursively from the mempool, as they would otherwise become orphans.
func (*MockTxMempool) TxDescs ¶
func (m *MockTxMempool) TxDescs() []*mempool.TxDesc
TxDescs returns a slice of descriptors for all the transactions in the pool.