txpool

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxSize int        `toml:"max_size"`
	Fee     *FeeConfig `toml:"fee"`

	// Private configuration
	ConsumptionWindow uint32 `toml:"-"`
}

Config defines parameters for the transaction pool.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default transaction pool configuration.

func (*Config) BasicCheck added in v0.15.0

func (conf *Config) BasicCheck() error

BasicCheck performs basic checks on the configuration.

type ConfigError added in v1.1.0

type ConfigError struct {
	Reason string
}

ConfigError is returned when the transaction pool configuration is invalid.

func (ConfigError) Error added in v1.1.0

func (e ConfigError) Error() string

type FeeConfig added in v1.6.0

type FeeConfig struct {
	FixedFee   float64 `toml:"fixed_fee"`
	DailyLimit int     `toml:"daily_limit"`
	UnitPrice  float64 `toml:"unit_price"`
}

FeeConfig holds fee-related settings used to estimate and validate transaction fees.

func DefaultFeeConfig added in v1.6.0

func DefaultFeeConfig() *FeeConfig

DefaultFeeConfig returns the default fee configuration.

type InvalidFeeError added in v1.6.0

type InvalidFeeError struct {
	MinimumFee amount.Amount
}

InvalidFeeError indicates that a transaction fee is below the required minimum.

func (InvalidFeeError) Error added in v1.6.0

func (e InvalidFeeError) Error() string

type MockTxPool

type MockTxPool struct {
	Txs         []*tx.Tx
	AppendError error
}

MockTxPool is a mock implementation of the TxPool interface for testing.

func MockingTxPool

func MockingTxPool() *MockTxPool

func (*MockTxPool) AllPendingTxs added in v1.3.0

func (m *MockTxPool) AllPendingTxs() []*tx.Tx

func (*MockTxPool) AppendTx

func (m *MockTxPool) AppendTx(trx *tx.Tx) error

func (*MockTxPool) AppendTxAndBroadcast

func (m *MockTxPool) AppendTxAndBroadcast(trx *tx.Tx) error

func (*MockTxPool) EstimatedFee added in v1.1.6

func (*MockTxPool) EstimatedFee(_ amount.Amount, _ payload.Type) amount.Amount

func (*MockTxPool) HandleCommittedBlock added in v1.6.0

func (*MockTxPool) HandleCommittedBlock(_ *block.Block)

func (*MockTxPool) HasTx

func (m *MockTxPool) HasTx(txID tx.ID) bool

func (*MockTxPool) PendingTx

func (m *MockTxPool) PendingTx(txID tx.ID) *tx.Tx

func (*MockTxPool) PrepareBlockTransactions

func (m *MockTxPool) PrepareBlockTransactions() block.Txs

func (*MockTxPool) QueryTx

func (m *MockTxPool) QueryTx(txID tx.ID) *tx.Tx

func (*MockTxPool) RemoveTx

func (m *MockTxPool) RemoveTx(id hash.Hash)

func (*MockTxPool) SetNewSandboxAndRecheck

func (*MockTxPool) SetNewSandboxAndRecheck(_ sandbox.Sandbox)

func (*MockTxPool) Size

func (m *MockTxPool) Size() int

func (*MockTxPool) String added in v0.15.0

func (*MockTxPool) String() string

type Reader

type Reader interface {
	PrepareBlockTransactions() block.Txs
	PendingTx(txID tx.ID) *tx.Tx
	HasTx(txID tx.ID) bool
	Size() int
	EstimatedFee(amt amount.Amount, payloadType payload.Type) amount.Amount
	AllPendingTxs() []*tx.Tx
}

Reader exposes read-only operations on the transaction pool.

type TxPool

type TxPool interface {
	Reader

	SetNewSandboxAndRecheck(sbx sandbox.Sandbox)
	AppendTxAndBroadcast(trx *tx.Tx) error
	AppendTx(trx *tx.Tx) error
	HandleCommittedBlock(blk *block.Block)
}

TxPool defines the full transaction pool interface with read and write operations.

func NewTxPool

func NewTxPool(conf *Config, storeReader store.Reader, messagePipe pipeline.Pipeline[message.Message]) TxPool

NewTxPool constructs a new transaction pool with sub-pools per transaction type. The pool also maintains a consumption map for tracking per-address daily byte usage.

Jump to

Keyboard shortcuts

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