txpool

package
v0.6.2-beta-0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIntrinsicGas            = errors.New("intrinsic gas too low")
	ErrBlockLimitExceeded      = errors.New("exceeds block gas limit")
	ErrNegativeValue           = errors.New("negative value")
	ErrExtractSignature        = errors.New("cannot extract signature")
	ErrInvalidSender           = errors.New("invalid sender")
	ErrTxPoolOverflow          = errors.New("txpool is full")
	ErrUnderpriced             = errors.New("transaction underpriced")
	ErrNonceTooLow             = errors.New("nonce too low")
	ErrInsufficientFunds       = errors.New("insufficient funds for gas * price + value")
	ErrInvalidAccountState     = errors.New("invalid account state")
	ErrAlreadyKnown            = errors.New("already known")
	ErrOversizedData           = errors.New("oversized data")
	ErrMaxEnqueuedLimitReached = errors.New("maximum number of enqueued transactions reached")
	ErrRejectFutureTx          = errors.New("rejected future tx due to low slots")
	ErrSmartContractRestricted = errors.New("smart contract deployment restricted")
)

errors

Functions

This section is empty.

Types

type Config

type Config struct {
	PriceLimit          uint64
	MaxSlots            uint64
	MaxAccountEnqueued  uint64
	DeploymentWhitelist []types.Address
}

type TxPool

type TxPool struct {

	// indicates which txpool operator commands should be implemented
	proto.UnimplementedTxnPoolOperatorServer
	// contains filtered or unexported fields
}

TxPool is a module that handles pending transactions. All transactions are handled within their respective accounts. An account contains 2 queues a transaction needs to go through: - 1. Enqueued (entry point) - 2. Promoted (exit point) (both queues are min nonce ordered)

When consensus needs to process promoted transactions, the pool generates a queue of "executable" transactions. These transactions are the first-in-line of some promoted queue, ready to be written to the state (primaries).

func NewTxPool

func NewTxPool(
	logger hclog.Logger,
	forks chain.ForksInTime,
	store store,
	grpcServer *grpc.Server,
	network *network.Server,
	config *Config,
) (*TxPool, error)

NewTxPool returns a new pool for processing incoming transactions.

func (*TxPool) AddTx

func (p *TxPool) AddTx(tx *types.Transaction) error

AddTx adds a new transaction to the pool (sent from json-RPC/gRPC endpoints) and broadcasts it to the network (if enabled).

func (*TxPool) AddTxn

func (p *TxPool) AddTxn(ctx context.Context, raw *proto.AddTxnReq) (*proto.AddTxnResp, error)

AddTxn adds a local transaction to the pool

func (*TxPool) Close

func (p *TxPool) Close()

Close shuts down the pool's main loop.

func (*TxPool) Demote

func (p *TxPool) Demote(tx *types.Transaction)

Demote excludes an account from being further processed during block building due to a recoverable error. If an account has been demoted too many times (maxAccountDemotions), it is Dropped instead.

func (*TxPool) Drop

func (p *TxPool) Drop(tx *types.Transaction)

Drop clears the entire account associated with the given transaction and reverts its next (expected) nonce.

func (*TxPool) GetCapacity

func (p *TxPool) GetCapacity() (uint64, uint64)

GetCapacity returns the current number of slots occupied in the pool as well as the max limit

func (*TxPool) GetNonce

func (p *TxPool) GetNonce(addr types.Address) uint64

GetNonce returns the next nonce for the account

-> Returns the value from the TxPool if the account is initialized in-memory

-> Returns the value from the world state otherwise

func (*TxPool) GetPendingTx

func (p *TxPool) GetPendingTx(txHash types.Hash) (*types.Transaction, bool)

GetPendingTx returns the transaction by hash in the TxPool (pending txn) [Thread-safe]

func (*TxPool) GetTxs

func (p *TxPool) GetTxs(inclQueued bool) (
	allPromoted, allEnqueued map[types.Address][]*types.Transaction,
)

GetTxs gets pending and queued transactions

func (*TxPool) Length

func (p *TxPool) Length() uint64

Length returns the total number of all promoted transactions.

func (*TxPool) Peek

func (p *TxPool) Peek() *types.Transaction

Peek returns the best-price selected transaction ready for execution.

func (*TxPool) Pop

func (p *TxPool) Pop(tx *types.Transaction)

Pop removes the given transaction from the associated promoted queue (account). Will update executables with the next primary from that account (if any).

func (*TxPool) Prepare

func (p *TxPool) Prepare()

Prepare generates all the transactions ready for execution. (primaries)

func (*TxPool) ResetWithHeaders

func (p *TxPool) ResetWithHeaders(headers ...*types.Header)

ResetWithHeaders processes the transactions from the new headers to sync the pool with the new state.

func (*TxPool) SetSealing

func (p *TxPool) SetSealing(sealing bool)

SetSealing sets the sealing flag

func (*TxPool) SetSigner

func (p *TxPool) SetSigner(s signer)

SetSigner sets the signer the pool will use to validate a transaction's signature.

func (*TxPool) Start

func (p *TxPool) Start()

Start runs the pool's main loop in the background. On each request received, the appropriate handler is invoked in a separate goroutine.

func (*TxPool) Status

func (p *TxPool) Status(ctx context.Context, req *empty.Empty) (*proto.TxnPoolStatusResp, error)

Status implements the GRPC status endpoint. Returns the number of transactions in the pool

func (*TxPool) Subscribe

func (p *TxPool) Subscribe(
	request *proto.SubscribeRequest,
	stream proto.TxnPoolOperator_SubscribeServer,
) error

Subscribe implements the operator endpoint. It subscribes to new events in the tx pool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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