txspool

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BloomFetcherMaxTime      = 10 * time.Minute
	BloomSendTransactionTime = 10 * time.Second
	BloomSendMaxTransactions = 100
)

Variables

View Source
var (
	ErrAlreadyKnown       = fmt.Errorf("already known")
	ErrInvalidSender      = fmt.Errorf("invalid sender")
	ErrOversizedData      = fmt.Errorf("oversized data")
	ErrNegativeValue      = fmt.Errorf("negative value")
	ErrGasLimit           = fmt.Errorf("exceeds block gas limit")
	ErrUnderpriced        = fmt.Errorf("transaction underpriced")
	ErrTxPoolOverflow     = fmt.Errorf("txpool is full")
	ErrReplaceUnderpriced = fmt.Errorf("replacement transaction underpriced")

	ErrFeeCapVeryHigh = fmt.Errorf("max fee per gas higher than 2^256-1")

	ErrNonceTooLow  = fmt.Errorf("nonce too low")
	ErrNonceTooHigh = fmt.Errorf("nonce too high")

	ErrInsufficientFunds = fmt.Errorf("insufficient funds for gas * price + value")

	// ErrTipAboveFeeCap is a sanity error to ensure no one is able to specify a
	// transaction with a tip higher than the total fee cap.
	ErrTipAboveFeeCap = fmt.Errorf("max priority fee per gas higher than max fee per gas")
)
View Source
var DefaultTxPoolConfig = TxsPoolConfig{

	PriceLimit: 1,
	PriceBump:  10,

	AccountSlots: 16,
	GlobalSlots:  4096 + 1024,
	AccountQueue: 64,
	GlobalQueue:  1024,

	Lifetime: 3 * time.Hour,
}

DefaultTxPoolConfig default blockchain

View Source
var (
	ErrBadPeer = fmt.Errorf("bad peer error")
)

Functions

func NewTxsPool

func NewTxsPool(ctx context.Context, bc common.IBlockChain, depositContract *deposit.Deposit) (common.ITxsPool, error)

Types

type ReadState added in v0.1.1

type ReadState interface {
	GetNonce(types.Address) uint64
	GetBalance(types.Address) *uint256.Int
	State(types.Address) (*account.StateAccount, error)
}

func StateClient added in v0.1.1

func StateClient(ctx context.Context, db kv.RoDB) ReadState

type StateCli added in v0.1.1

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

func (*StateCli) GetBalance added in v0.1.1

func (c *StateCli) GetBalance(addr types.Address) *uint256.Int

func (*StateCli) GetNonce added in v0.1.1

func (c *StateCli) GetNonce(addr types.Address) uint64

func (*StateCli) State added in v0.1.1

func (c *StateCli) State(addr types.Address) (*account.StateAccount, error)

type TxByNonce

type TxByNonce []*transaction.Transaction

TxByNonce implements the sort interface to allow sorting a list of transactions by their nonces.

func (TxByNonce) Len

func (s TxByNonce) Len() int

func (TxByNonce) Less

func (s TxByNonce) Less(i, j int) bool

func (TxByNonce) Swap

func (s TxByNonce) Swap(i, j int)

type TxsFetcher

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

func NewTxsFetcher

func NewTxsFetcher(ctx context.Context, getTx func(hash types.Hash) *transaction.Transaction, addTxs func([]*transaction.Transaction) []error, pendingTxs func(enforceTips bool) map[types.Address][]*transaction.Transaction, p2pServer common.INetwork, peers common.PeerMap, bloom *types.Bloom) *TxsFetcher

func (TxsFetcher) ConnHandler

func (f TxsFetcher) ConnHandler(data []byte, ID peer.ID) error

ConnHandler handler peer message

func (TxsFetcher) Start

func (f TxsFetcher) Start() error

type TxsPool

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

func (*TxsPool) AddLocal

func (pool *TxsPool) AddLocal(tx *transaction.Transaction) error

AddLocal

func (*TxsPool) AddLocals

func (pool *TxsPool) AddLocals(txs []*transaction.Transaction) []error

AddLocals

func (*TxsPool) AddRemotes

func (pool *TxsPool) AddRemotes(txs []*transaction.Transaction) []error

AddRemotes

func (*TxsPool) Content

func (pool *TxsPool) Content() (map[types.Address][]*transaction.Transaction, map[types.Address][]*transaction.Transaction)

Content

func (*TxsPool) GetTransaction

func (pool *TxsPool) GetTransaction() (txs []*transaction.Transaction, err error)

GetTransaction

func (*TxsPool) GetTx

func (pool *TxsPool) GetTx(hash types.Hash) *transaction.Transaction

GetTx

func (*TxsPool) Has

func (pool *TxsPool) Has(hash types.Hash) bool

Has

func (*TxsPool) Nonce

func (pool *TxsPool) Nonce(addr types.Address) uint64

func (*TxsPool) Pending

func (pool *TxsPool) Pending(enforceTips bool) map[types.Address][]*transaction.Transaction

Pending retrieves all currently processable transactions, grouped by origin account and sorted by nonce. The returned transaction set is a copy and can be freely modified by calling code.

The enforceTips parameter can be used to do an extra filtering on the pending transactions and only return those whose **effective** tip is large enough in the next pending execution environment.

func (*TxsPool) ResetState

func (pool *TxsPool) ResetState(blockHash types.Hash) error

func (*TxsPool) Stats

func (pool *TxsPool) Stats() (int, int, int, int)

func (*TxsPool) StatsPrint

func (pool *TxsPool) StatsPrint()

StatsPrint

func (*TxsPool) Stop

func (pool *TxsPool) Stop() error

Stop terminates the transaction pool.

type TxsPoolConfig

type TxsPoolConfig struct {
	Locals   []types.Address
	NoLocals bool

	PriceLimit uint64
	PriceBump  uint64

	AccountSlots uint64
	GlobalSlots  uint64
	AccountQueue uint64
	GlobalQueue  uint64

	Lifetime time.Duration
}

Jump to

Keyboard shortcuts

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