txpool

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTxPoolOptions = Options{
	Limit:           200000,
	LimitPerAccount: 1024,
	MaxLifetime:     20 * time.Minute,
}

Functions

func IsBadTx

func IsBadTx(err error) bool

IsBadTx returns whether the given error indicates that tx is bad.

func IsTxRejected

func IsTxRejected(err error) bool

IsTxRejected returns whether the given error indicates tx is rejected.

Types

type MempoolAdapter added in v0.3.16

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

MempoolAdapter adapts Supernova's TxPool to implement CometBFT's mempool interface This allows Cosmos SDK modules to interact with the txpool through the standard mempool interface

func NewMempoolAdapter added in v0.3.16

func NewMempoolAdapter(txPool *TxPool, proxyApp cmtproxy.AppConnMempool, config *MempoolConfig) *MempoolAdapter

NewMempoolAdapter creates a new mempool adapter

func (*MempoolAdapter) CheckTx added in v0.3.16

func (m *MempoolAdapter) CheckTx(tx cmttypes.Tx, peerID p2p.ID) (*abcicli.ReqRes, error)

CheckTx checks if a transaction is valid and adds it to the mempool

func (*MempoolAdapter) CloseWAL added in v0.3.16

func (m *MempoolAdapter) CloseWAL()

CloseWAL closes the write-ahead log

func (*MempoolAdapter) Contains added in v0.3.25

func (m *MempoolAdapter) Contains(txKey cmttypes.TxKey) bool

Contains checks if a transaction with the given key exists in the mempool

func (*MempoolAdapter) EnableTxsAvailable added in v0.3.16

func (m *MempoolAdapter) EnableTxsAvailable()

EnableTxsAvailable enables the TxsAvailable channel

func (*MempoolAdapter) Flush added in v0.3.16

func (m *MempoolAdapter) Flush()

Flush removes all transactions from the mempool

func (*MempoolAdapter) FlushAppConn added in v0.3.16

func (m *MempoolAdapter) FlushAppConn() error

FlushAppConn flushes the application connection

func (*MempoolAdapter) GetSenders added in v0.3.25

func (m *MempoolAdapter) GetSenders(txKey cmttypes.TxKey) ([]p2p.ID, error)

GetSenders returns a slice of unique p2p.IDs for the given transaction key. This is a stub implementation; update as needed to extract sender IDs from your transactions.

func (*MempoolAdapter) GetTxByHash added in v0.3.25

func (m *MempoolAdapter) GetTxByHash(hash []byte) cmttypes.Tx

GetTxByHash returns the transaction corresponding to the given hash, or nil if not found.

func (*MempoolAdapter) GetTxPool added in v0.3.16

func (m *MempoolAdapter) GetTxPool() *TxPool

GetTxPool returns the underlying TxPool for direct access if needed

func (*MempoolAdapter) InMempool added in v0.3.16

func (m *MempoolAdapter) InMempool(txKey cmttypes.TxKey) bool

InMempool checks if a transaction is in the mempool

func (*MempoolAdapter) InitWAL added in v0.3.16

func (m *MempoolAdapter) InitWAL() error

InitWAL initializes the write-ahead log

func (*MempoolAdapter) Lock added in v0.3.16

func (m *MempoolAdapter) Lock()

Lock locks the mempool

func (*MempoolAdapter) PreUpdate added in v0.3.16

func (m *MempoolAdapter) PreUpdate()

PreUpdate is called before a block is committed

func (*MempoolAdapter) ReapMaxBytesMaxGas added in v0.3.16

func (m *MempoolAdapter) ReapMaxBytesMaxGas(maxBytes, maxGas int64) cmttypes.Txs

ReapMaxBytesMaxGas reaps transactions from the mempool up to maxBytes and maxGas

func (*MempoolAdapter) ReapMaxTxs added in v0.3.16

func (m *MempoolAdapter) ReapMaxTxs(max int) cmttypes.Txs

ReapMaxTxs reaps up to max transactions from the mempool

func (*MempoolAdapter) RemoveTxByKey added in v0.3.16

func (m *MempoolAdapter) RemoveTxByKey(txKey cmttypes.TxKey) error

RemoveTxByKey removes a transaction from the mempool by its key

func (*MempoolAdapter) Size added in v0.3.16

func (m *MempoolAdapter) Size() int

Size returns the number of transactions in the mempool

func (*MempoolAdapter) SizeBytes added in v0.3.16

func (m *MempoolAdapter) SizeBytes() int64

SizeBytes returns the total size of all transactions in the mempool

func (*MempoolAdapter) TxsAvailable added in v0.3.16

func (m *MempoolAdapter) TxsAvailable() <-chan struct{}

TxsAvailable returns a channel that fires when transactions are available

func (*MempoolAdapter) TxsBytes added in v0.3.16

func (m *MempoolAdapter) TxsBytes() int64

TxsBytes returns the total size of all transactions in bytes

func (*MempoolAdapter) TxsWaitChan added in v0.3.16

func (m *MempoolAdapter) TxsWaitChan() <-chan struct{}

TxsWaitChan returns a channel that fires when transactions are available

func (*MempoolAdapter) Unlock added in v0.3.16

func (m *MempoolAdapter) Unlock()

Unlock unlocks the mempool

func (*MempoolAdapter) Update added in v0.3.16

func (m *MempoolAdapter) Update(
	blockHeight int64,
	blockTxs cmttypes.Txs,
	txResults []*abci.ExecTxResult,
	preCheck mempl.PreCheckFunc,
	postCheck mempl.PostCheckFunc,
) error

Update updates the mempool after a block has been committed

type MempoolConfig added in v0.3.16

type MempoolConfig struct {
	RecheckEmpty   bool
	RecheckTimeout time.Duration
	Broadcast      bool
	WalPath        string
}

type Options

type Options struct {
	Limit           int
	LimitPerAccount int
	MaxLifetime     time.Duration
}

Options options for tx pool.

type TxEvent

type TxEvent struct {
	Tx         cmttypes.Tx
	Executable *bool
}

TxEvent will be posted when tx is added or status changed.

type TxPool

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

TxPool maintains unprocessed transactions.

func New

func New(chain *chain.Chain, options Options) *TxPool

New create a new TxPool instance. Shutdown is required to be called at end.

func (*TxPool) Add

func (p *TxPool) Add(newTx cmttypes.Tx) error

Add add new tx into pool. It's not assumed as an error if the tx to be added is already in the pool,

func (*TxPool) All

func (p *TxPool) All() []*txObject

func (*TxPool) Close

func (p *TxPool) Close()

Close cleanup inner go routines.

func (*TxPool) Dump

func (p *TxPool) Dump() types.Transactions

Dump dumps all txs in the pool.

func (*TxPool) Executables

func (p *TxPool) Executables() types.Transactions

Executables returns executable txs.

func (*TxPool) Fill

func (p *TxPool) Fill(txs types.Transactions, executed func(txID []byte) bool)

Fill fills txs into pool.

func (*TxPool) Get

func (p *TxPool) Get(id []byte) cmttypes.Tx

func (*TxPool) GetNewTxFeed

func (p *TxPool) GetNewTxFeed() chan []byte

func (*TxPool) GetTxObj

func (p *TxPool) GetTxObj(id []byte) *txObject

func (*TxPool) Len

func (p *TxPool) Len() int

func (*TxPool) LenBytes added in v0.3.13

func (p *TxPool) LenBytes() int64

func (*TxPool) ReapMaxTxs added in v0.3.13

func (p *TxPool) ReapMaxTxs(limit int) types.Transactions

func (*TxPool) Remove

func (p *TxPool) Remove(id []byte) bool

Remove removes tx from pool by its ID.

func (*TxPool) StrictlyAdd

func (p *TxPool) StrictlyAdd(newTx cmttypes.Tx) error

StrictlyAdd add new tx into pool. A rejection error will be returned, if tx is not executable at this time.

func (*TxPool) SubscribeTxEvent

func (p *TxPool) SubscribeTxEvent(ch chan *TxEvent) event.Subscription

SubscribeTxEvent receivers will receive a tx

Jump to

Keyboard shortcuts

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