txpool

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOutOfGas is returned if the transaction executing out of gas
	ErrOutOfGas = errors.New("out of gas")
	// ErrInvalidSender is returned if the transaction contains an invalid signature.
	ErrInvalidSender = errors.New("invalid sender")

	// ErrNonceTooLow is returned if the nonce of a transaction is lower than the
	// one present in the local chain.
	ErrNonceTooLow = errors.New("nonce too low")

	// ErrUnderpriced is returned if a transaction's gas price is below the minimum
	// configured for the transaction pool.
	ErrUnderpriced = errors.New("transaction underpriced")

	// ErrReplaceUnderpriced is returned if a transaction is attempted to be replaced
	// with a different one without the required price bump.
	ErrReplaceUnderpriced = errors.New("replacement transaction underpriced")

	// ErrInsufficientFundsForGas is returned if the gas cost of executing a transaction
	// is higher than the balance of the user's account.
	ErrInsufficientFundsForGas = errors.New("insufficient funds for gas * price")

	// ErrInsufficientFundsForValue is returned if the value cost of executing a transaction
	// is higher than the balance of the user's account.
	ErrInsufficientFundsForValue = errors.New("insufficient funds for value")

	// ErrIntrinsicGas is returned if the transaction is specified to use less gas
	// than required to start the invocation.
	ErrIntrinsicGas = errors.New("intrinsic gas too low")

	// ErrGasLimit is returned if a transaction's requested gas limit exceeds the
	// maximum allowance of the current block.
	ErrGasLimit = errors.New("exceeds block gas limit")

	// ErrNegativeValue is a sanity error to ensure noone is able to specify a
	// transaction with a negative value.
	ErrNegativeValue = errors.New("negative value")
)
View Source
var DefaultTxPoolConfig = &Config{
	Journal:        "transactions.rlp",
	Rejournal:      time.Hour,
	PriceLimit:     1000000000,
	PriceBump:      10,
	AccountSlots:   128,
	GlobalSlots:    4096,
	AccountQueue:   1280,
	GlobalQueue:    4096,
	Lifetime:       3 * time.Hour,
	ResendTime:     10 * time.Minute,
	MinBroadcast:   3,
	RatioBroadcast: 3,
}

DefaultTxPoolConfig default txpool config

View Source
var SenderCacher = newTxSenderCacher(runtime.NumCPU())

SenderCacher is a concurrent tranaction sender recoverer anc cacher.

Functions

func IntrinsicGas

func IntrinsicGas(accountDB *accountmanager.AccountManager, action *types.Action) (uint64, error)

IntrinsicGas computes the 'intrinsic gas' for a message with the given data.

Types

type Config

type Config struct {
	NoLocals  bool          `mapstructure:"nolocals"`  // Whether local transaction handling should be disabled
	Journal   string        `mapstructure:"journal"`   // Journal of local transactions to survive node restarts
	Rejournal time.Duration `mapstructure:"rejournal"` // Time interval to regenerate the local transaction journal

	PriceLimit uint64 `mapstructure:"pricelimit"` // Minimum gas price to enforce for acceptance into the pool
	PriceBump  uint64 `mapstructure:"pricebump"`  // Minimum price bump percentage to replace an already existing transaction (nonce)

	AccountSlots uint64 `mapstructure:"accountslots"` // Minimum number of executable transaction slots guaranteed per account
	GlobalSlots  uint64 `mapstructure:"globalslots"`  // Maximum number of executable transaction slots for all accounts
	AccountQueue uint64 `mapstructure:"accountqueue"` // Maximum number of non-executable transaction slots permitted per account
	GlobalQueue  uint64 `mapstructure:"globalqueue"`  // Maximum number of non-executable transaction slots for all accounts

	Lifetime   time.Duration `mapstructure:"lifetime"`   // Maximum amount of time non-executable transaction are queued
	ResendTime time.Duration `mapstructure:"resendtime"` // Maximum amount of time  executable transaction are resended

	MinBroadcast   uint64 `mapstructure:"minbroadcast"`   // Minimum number of nodes for the transaction broadcast
	RatioBroadcast uint64 `mapstructure:"ratiobroadcast"` // Ratio of nodes for the transaction broadcast
	GasAssetID     uint64
}

Config are the configuration parameters of the transaction pool.

type TransactionWithPath added in v0.0.8

type TransactionWithPath struct {
	Tx    *types.Transaction
	Bloom *types.Bloom
}

TransactionWithPath is the network packet for the transactions.

type TxPool

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

TxPool contains all currently known transactions.

func New

func New(config Config, chainconfig *params.ChainConfig, bc blockChain) *TxPool

New creates a new transaction pool to gather, sort and filter inbound transactions from the network.

func (*TxPool) AddLocal

func (tp *TxPool) AddLocal(tx *types.Transaction) error

AddLocal enqueues a single local transaction into the pool if it is valid. This is a convenience wrapper aroundd AddLocals.

func (*TxPool) AddLocals

func (tp *TxPool) AddLocals(txs []*types.Transaction) []error

AddLocals enqueues a batch of transactions into the pool if they are valid, marking the senders as a local ones, ensuring they go around the local pricing constraints.

This method is used to add transactions from the RPC API and performs synchronous pool reorganization and event propagation.

func (*TxPool) AddRemote deprecated

func (tp *TxPool) AddRemote(tx *types.Transaction) error

AddRemote enqueues a single transaction into the pool if it is valid. This is a convenience wrapper around AddRemotes.

Deprecated: use AddRemotes

func (*TxPool) AddRemotes

func (tp *TxPool) AddRemotes(txs []*types.Transaction) []error

AddRemotes enqueues a batch of transactions into the pool if they are valid. If the senders are not among the locally tracked ones, full pricing constraints will apply.

This method is used to add transactions from the p2p network and does not wait for pool reorganization and internal event propagation.

func (*TxPool) Content

func (tp *TxPool) Content() (map[common.Name][]*types.Transaction, map[common.Name][]*types.Transaction)

Content retrieves the data content of the transaction pool, returning all the pending as well as queued transactions, grouped by account and sorted by nonce.

func (*TxPool) GasPrice

func (tp *TxPool) GasPrice() *big.Int

GasPrice returns the current gas price enforced by the transaction tp.

func (*TxPool) Get

func (tp *TxPool) Get(hash common.Hash) *types.Transaction

Get returns a transaction if it is contained in the pool and nil otherwise.

func (*TxPool) Pending

func (tp *TxPool) Pending() (map[common.Name][]*types.Transaction, error)

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

func (*TxPool) SetGasPrice

func (tp *TxPool) SetGasPrice(price *big.Int)

SetGasPrice updates the minimum price required by the transaction pool for a new transaction, and drops all transactions below this threshold.

func (*TxPool) State

func (tp *TxPool) State() *am.AccountManager

State returns the virtual managed state of the transaction tp.

func (*TxPool) Stats

func (tp *TxPool) Stats() (int, int)

Stats retrieves the current pool stats, namely the number of pending and the number of queued (non-executable) transactions.

func (*TxPool) Status

func (tp *TxPool) Status(hashes []common.Hash) []TxStatus

Status returns the status (unknown/pending/queued) of a batch of transactions identified by their hashes.

func (*TxPool) Stop

func (tp *TxPool) Stop()

Stop terminates the transaction tp.

type TxStatus

type TxStatus uint

TxStatus is the current status of a transaction as seen by the tp.

const (
	TxStatusUnknown TxStatus = iota
	TxStatusQueued
	TxStatusPending
	TxStatusIncluded
)

type TxpoolStation

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

TxpoolStation is responsible for transaction broadcasting and receiving

func NewTxpoolStation

func NewTxpoolStation(txpool *TxPool) *TxpoolStation

NewTxpoolStation create a new TxpoolStation

func (*TxpoolStation) Stop added in v0.0.15

func (s *TxpoolStation) Stop()

Jump to

Keyboard shortcuts

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