Documentation
¶
Index ¶
- type CheckFn
- type Mempool
- func (mp *Mempool) CapMaxTxSize(maxBlockSize int64)
- 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) SetMaxTxSize(maxBytes int64)
- func (mp *Mempool) Size() (totalBytes, numTxns int)
- func (mp *Mempool) Store(tx *types.Tx) error
- 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) CapMaxTxSize ¶ added in v0.10.1
CapMaxTxSize updates the maximum allowed transaction size based on the network parameter maxBlockSize.
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) SetMaxTxSize ¶ added in v0.10.1
SetMaxSize updates the maximum allowed transaction 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. It returns an error if the transaction cannot be stored, such as if the transaction already exists, exceeds the maximum allowed transaction size,or if the mempool is full. 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.