txpool

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 16 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 configs
	ConsumptionWindow uint32 `toml:"-"`
}

func DefaultConfig

func DefaultConfig() *Config

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 txPool 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"`
}

func DefaultFeeConfig added in v1.6.0

func DefaultFeeConfig() *FeeConfig

type InvalidFeeError added in v1.6.0

type InvalidFeeError struct {
	MinimumFee amount.Amount
}

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

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 testing mock.

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
}

type TxPool

type TxPool interface {
	Reader

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

func NewTxPool

func NewTxPool(conf *Config, storeReader store.Reader, broadcastCh chan message.Message) TxPool

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

Jump to

Keyboard shortcuts

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