txpool

package
v0.15.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflictingAtomicTx     = errors.New("conflicting atomic tx present")
	ErrInsufficientAtomicTxFee = errors.New("atomic tx fee too low for atomic mempool")
	ErrTooManyAtomicTx         = errors.New("too many atomic tx")
)

Functions

This section is empty.

Types

type Mempool

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

Mempool is a simple mempool for atomic transactions

func NewMempool

func NewMempool(ctx *snow.Context, registerer prometheus.Registerer, maxSize int, verify func(tx *atomic.Tx) error) (*Mempool, error)

NewMempool returns a Mempool with [maxSize]

func (*Mempool) Add

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

func (*Mempool) AddLocalTx

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

func (*Mempool) AddRemoteTx

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

AddRemoteTx attempts to add [tx] to the mempool and returns an error if it could not be added to the mempool.

func (*Mempool) CancelCurrentTx

func (m *Mempool) 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 (*Mempool) CancelCurrentTxs

func (m *Mempool) 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 (*Mempool) DiscardCurrentTx

func (m *Mempool) 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 (*Mempool) DiscardCurrentTxs

func (m *Mempool) DiscardCurrentTxs()

DiscardCurrentTxs marks all txs in [currentTxs] as discarded.

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)

func (*Mempool) GetPendingTx

func (m *Mempool) 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 (*Mempool) GetTx

func (m *Mempool) 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 (*Mempool) Has

func (m *Mempool) Has(txID ids.ID) bool

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

func (*Mempool) IssueCurrentTxs

func (m *Mempool) IssueCurrentTxs()

IssueCurrentTx marks [currentTx] as issued if there is one

func (*Mempool) Iterate

func (m *Mempool) Iterate(f func(tx *atomic.Tx) bool)

func (*Mempool) Len

func (m *Mempool) Len() int

Len returns the number of transactions in the mempool

func (*Mempool) NextTx

func (m *Mempool) NextTx() (*atomic.Tx, bool)

NextTx returns a transaction to be issued from the mempool.

func (*Mempool) RemoveTx

func (m *Mempool) RemoveTx(tx *atomic.Tx)

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

func (*Mempool) SubscribePendingTxs

func (m *Mempool) 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