txpool

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: GPL-3.0, LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyKnown    = errors.New("already known")
	ErrConflict        = errors.New("conflict present")
	ErrInsufficientFee = errors.New("insufficient fee")
	ErrMempoolFull     = errors.New("mempool full")
)
View Source
var ErrNoGasUsed = errors.New("no gas used")

Functions

This section is empty.

Types

type Mempool

type Mempool struct {
	*Txs
	// contains filtered or unexported fields
}

Mempool is a simple mempool for atomic transactions

func NewMempool

func NewMempool(
	txs *Txs,
	registerer prometheus.Registerer,
	verify func(tx *atomic.Tx) error,
) (*Mempool, error)

func (*Mempool) Add

func (m *Mempool) Add(tx *atomic.Tx) error

Add attempts to add tx to the mempool as a Remote transaction. It is assumed the snow context lock is not held.

func (*Mempool) AddLocalTx

func (m *Mempool) AddLocalTx(tx *atomic.Tx) error

AddLocalTx attempts to add tx to the mempool as a Local transaction.

Local transactions are not checked for recent verification failures prior to performing verification. Even if a Local transaction failed verification recently, the mempool will attempt to re-verify it.

func (*Mempool) AddRemoteTx

func (m *Mempool) AddRemoteTx(tx *atomic.Tx) error

AddRemoteTx attempts to add tx to the mempool as a Remote transaction.

Remote transactions are checked for recent verification failures prior to performing verification. If a Remote transaction failed verification recently it will not be added to the mempool.

func (*Mempool) ForceAddTx

func (m *Mempool) ForceAddTx(tx *atomic.Tx) error

ForceAddTx forcibly adds a *atomic.Tx to the mempool and bypasses all verification.

func (*Mempool) GetFilter

func (m *Mempool) GetFilter() ([]byte, []byte)

type Txs added in v1.13.3

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

func NewTxs added in v1.13.3

func NewTxs(ctx *snow.Context, maxSize int) *Txs

func (*Txs) CancelCurrentTx added in v1.13.3

func (t *Txs) CancelCurrentTx(txID ids.ID)

CancelCurrentTx marks the attempt to issue [txID] as being aborted. This should be called after NextTx returns [txID] and the transaction [txID] cannot be included in the block, but should not be discarded. For example, CancelCurrentTx should be called if including the transaction will put the block above the atomic tx gas limit.

func (*Txs) CancelCurrentTxs added in v1.13.3

func (t *Txs) CancelCurrentTxs()

[CancelCurrentTxs] marks the attempt to issue [currentTxs] as being aborted. If this is called after a buildBlock error caused by the atomic transaction, then DiscardCurrentTx should have been called such that this call will have no effect and should not re-issue the invalid tx.

func (*Txs) DiscardCurrentTx added in v1.13.3

func (t *Txs) DiscardCurrentTx(txID ids.ID)

DiscardCurrentTx marks a [tx] in the [currentTxs] map as invalid and aborts the attempt to issue it since it failed verification.

func (*Txs) DiscardCurrentTxs added in v1.13.3

func (t *Txs) DiscardCurrentTxs()

DiscardCurrentTxs marks all txs in [currentTxs] as discarded.

func (*Txs) GetPendingTx added in v1.13.3

func (t *Txs) GetPendingTx(txID ids.ID) (*atomic.Tx, bool)

GetPendingTx returns the transaction [txID] and true if it is currently in the [txHeap] waiting to be issued into a block. Returns nil, false otherwise.

func (*Txs) GetTx added in v1.13.3

func (t *Txs) GetTx(txID ids.ID) (*atomic.Tx, bool, bool)

GetTx returns the transaction [txID] if it was issued by this node and returns whether it was dropped and whether it exists.

func (*Txs) Has added in v1.13.3

func (t *Txs) Has(txID ids.ID) bool

Has returns true if the mempool contains [txID] or it was issued.

func (*Txs) IssueCurrentTxs added in v1.13.3

func (t *Txs) IssueCurrentTxs()

IssueCurrentTx marks [currentTx] as issued if there is one

func (*Txs) Iterate added in v1.13.3

func (t *Txs) Iterate(f func(tx *atomic.Tx) bool)

func (*Txs) Len added in v1.13.3

func (t *Txs) Len() int

Len returns the number of transactions

func (*Txs) NextTx added in v1.13.3

func (t *Txs) NextTx() (*atomic.Tx, bool)

NextTx returns a transaction to be issued from the mempool.

func (*Txs) PendingLen added in v1.13.3

func (t *Txs) PendingLen() int

PendingLen returns the number of pending transactions

func (*Txs) RemoveTx added in v1.13.3

func (t *Txs) RemoveTx(tx *atomic.Tx)

RemoveTx removes [txID] from the mempool completely. Evicts [tx] from the discarded cache if present.

func (*Txs) SubscribePendingTxs added in v1.13.3

func (t *Txs) SubscribePendingTxs() <-chan struct{}

SubscribePendingTxs implements the BuilderMempool interface and returns a channel that signals when there is at least one pending transaction in the mempool

Jump to

Keyboard shortcuts

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