mempool

package
v0.48.86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxNotFound           = errors.New("tx not found in mempool")
	ErrMempoolTxMaxCapacity = errors.New("pool reached max tx capacity")
)
View Source
var DefaultMaxTx = 0

Functions

func IsEmpty

func IsEmpty(mempool Mempool) error

Types

type Iterator

type Iterator interface {
	// Next returns the next transaction from the mempool. If there are no more
	// transactions, it returns nil.
	Next() Iterator

	// Tx returns the transaction at the current position of the iterator.
	Tx() sdk.Tx
}

Iterator defines an app-side mempool iterator interface that is as minimal as possible. The order of iteration is determined by the app-side mempool implementation.

type Mempool

type Mempool interface {
	// Insert attempts to insert a Tx into the app-side mempool returning
	// an error upon failure.
	Insert(context.Context, sdk.Tx) error

	// Select returns an Iterator over the app-side mempool. If txs are specified,
	// then they shall be incorporated into the Iterator. The Iterator must
	// closed by the caller.
	Select(context.Context, [][]byte) Iterator

	// CountTx returns the number of transactions currently in the mempool.
	CountTx() int

	// Remove attempts to remove a transaction from the mempool, returning an error
	// upon failure.
	Remove(sdk.Tx) error
}

func DefaultPriorityMempool

func DefaultPriorityMempool() Mempool

DefaultPriorityMempool returns a priorityNonceMempool with no options.

func NewPriorityMempool

func NewPriorityMempool(opts ...PriorityNonceMempoolOption) Mempool

NewPriorityMempool returns the SDK's default mempool implementation which returns txs in a partial order by 2 dimensions; priority, and sender-nonce.

func NewSenderNonceMempool

func NewSenderNonceMempool(opts ...SenderNonceOptions) Mempool

NewSenderNonceMempool creates a new mempool that prioritizes transactions by nonce, the lowest first, picking a random sender on each iteration.

type NoOpMempool

type NoOpMempool struct{}

NoOpMempool defines a no-op mempool. Transactions are completely discarded and ignored when BaseApp interacts with the mempool.

Note: When this mempool is used, it assumed that an application will rely on Tendermint's transaction ordering defined in `RequestPrepareProposal`, which is FIFO-ordered by default.

func (NoOpMempool) CountTx

func (NoOpMempool) CountTx() int

func (NoOpMempool) Insert

func (NoOpMempool) Remove

func (NoOpMempool) Remove(sdk.Tx) error

func (NoOpMempool) Select

func (NoOpMempool) Select(context.Context, [][]byte) Iterator

type PriorityNonceMempoolOption

type PriorityNonceMempoolOption func(*priorityNonceMempool)

func PriorityNonceWithMaxTx

func PriorityNonceWithMaxTx(maxTx int) PriorityNonceMempoolOption

PriorityNonceWithMaxTx sets the maximum number of transactions allowed in the mempool with the semantics:

<0: disabled, `Insert` is a no-op 0: unlimited >0: maximum number of transactions allowed

func PriorityNonceWithOnRead

func PriorityNonceWithOnRead(onRead func(tx sdk.Tx)) PriorityNonceMempoolOption

PriorityNonceWithOnRead sets a callback to be called when a tx is read from the mempool.

type SenderNonceOptions

type SenderNonceOptions func(mp *senderNonceMempool)

func SenderNonceMaxTxOpt

func SenderNonceMaxTxOpt(maxTx int) SenderNonceOptions

SenderNonceMaxTxOpt Option To set limit of max tx when calling the constructor NewSenderNonceMempool.

Example:

NewSenderNonceMempool(SenderNonceMaxTxOpt(100))

func SenderNonceSeedOpt

func SenderNonceSeedOpt(seed int64) SenderNonceOptions

SenderNonceSeedOpt Option To add a Seed for random type when calling the constructor NewSenderNonceMempool.

Example:

random_seed := int64(1000)
NewSenderNonceMempool(SenderNonceSeedTxOpt(random_seed))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL