mempool

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMaxTx = 0

Functions

This section is empty.

Types

type EvmSenderNonceMempool

type EvmSenderNonceMempool struct {
	// contains filtered or unexported fields
}

EvmSenderNonceMempool is a mempool that prioritizes transactions within a sender by nonce, the lowest first, but selects a random sender on each iteration. Additionality it supports evm custom message handling. The mempool is iterated by:

1) Maintaining a separate list of nonce ordered txs per sender 2) For each select iteration, randomly choose a sender and pick the next nonce ordered tx from their list 3) Repeat 1,2 until the mempool is exhausted

Note that PrepareProposal could choose to stop iteration before reaching the end if maxBytes is reached.

func NewEvmSenderNonceMempool

func NewEvmSenderNonceMempool(opts ...EvmSenderNonceOptions) *EvmSenderNonceMempool

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

func (*EvmSenderNonceMempool) CountTx

func (snm *EvmSenderNonceMempool) CountTx() int

CountTx returns the total count of txs in the mempool.

func (*EvmSenderNonceMempool) Insert

func (snm *EvmSenderNonceMempool) Insert(_ context.Context, tx sdk.Tx) error

Insert adds a tx to the mempool. It returns an error if the tx does not have at least one signer. Note, priority is ignored.

func (*EvmSenderNonceMempool) NextSenderTx

func (mp *EvmSenderNonceMempool) NextSenderTx(sender string) sdk.Tx

NextSenderTx returns the next transaction for a given sender by nonce order, i.e. the next valid transaction for the sender. If no such transaction exists, nil will be returned.

func (*EvmSenderNonceMempool) Remove

func (snm *EvmSenderNonceMempool) Remove(tx sdk.Tx) error

Remove removes a tx from the mempool. It returns an error if the tx does not have at least one signer or the tx was not found in the pool.

func (*EvmSenderNonceMempool) Select

func (snm *EvmSenderNonceMempool) Select(_ context.Context, _ [][]byte) mempool.Iterator

Select returns an iterator ordering transactions the mempool with the lowest nonce of a random selected sender first.

NOTE: It is not safe to use this iterator while removing transactions from the underlying mempool.

type EvmSenderNonceOptions

type EvmSenderNonceOptions func(mp *EvmSenderNonceMempool)

func SenderNonceMaxTxOpt

func SenderNonceMaxTxOpt(maxTx int) EvmSenderNonceOptions

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

Example:

NewEvmSenderNonceMempool(SenderNonceMaxTxOpt(100))

func SenderNonceSeedOpt

func SenderNonceSeedOpt(seed int64) EvmSenderNonceOptions

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

Example:

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

Jump to

Keyboard shortcuts

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