Documentation
¶
Index ¶
- type CheckFn
- type Mempool
- func (mp *Mempool) Get(txid types.Hash) *types.Tx
- func (mp *Mempool) Have(txid types.Hash) bool
- func (mp *Mempool) PeekN(n, szLimit int) []*types.Tx
- func (mp *Mempool) PreFetch(txid types.Hash) (bool, func())
- func (mp *Mempool) ReapN(n int) []*types.Tx
- func (mp *Mempool) RecheckTxs(ctx context.Context, fn CheckFn)
- func (mp *Mempool) Remove(txid types.Hash)
- func (mp *Mempool) SetMaxSize(maxBytes int64)
- func (mp *Mempool) Size() (totalBytes, numTxns int)
- func (mp *Mempool) Store(tx *types.Tx) (found, rejected bool)
- func (mp *Mempool) TxsAvailable() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
Mempool maintains a thread-safe pool of unconfirmed transactions with size limits.
func New ¶
New creates a new Mempool instance with a default max size of 200MB. See also SetMaxSize.
func (*Mempool) PeekN ¶
PeekN returns up to n transactions from the front of the queue without removing them, the number of transactions returned may be less than n if the total size in bytes of the transactions exceeds szLimit.
func (*Mempool) PreFetch ¶
PreFetch marks a transaction as being fetched. Returns true if the tx should be fetched. Always defer the returned "done" function if true is returned.
func (*Mempool) RecheckTxs ¶
RecheckTxs validates all transactions in the mempool using the provided check function, removing any that fail validation. This function will check the transaction queue in order.
func (*Mempool) SetMaxSize ¶
SetMaxSize updates the maximum allowed size in bytes for the mempool.
func (*Mempool) Size ¶
Size returns the current total size in bytes and number of transactions in the mempool.
func (*Mempool) Store ¶
Store adds a transaction to the mempool. Returns (found, rejected) where found indicates if the tx was already present, and rejected indicates if it was rejected due to size limits. To remove a transaction, use [Remove]; this will panic with a nil pointer.
func (*Mempool) TxsAvailable ¶
TxsAvailable returns true if there are any transactions in the mempool.