mempool

package
v0.47.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 93

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

This section is empty.

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(sdk.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 be closed by the caller.
	Select(sdk.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 NewSenderNonceMempool

func NewSenderNonceMempool(opts ...SenderNonceOptions) Mempool

NewSenderNonceMempool creates a new mempool that prioritizes transactions by nonce, the lowest first.

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