Documentation ¶
Index ¶
- Variables
- type Config
- type TxPool
- func (pool *TxPool) AddLocal(tx *types.Transaction) error
- func (pool *TxPool) AddLocals(txs []*types.Transaction) []error
- func (pool *TxPool) AddRemote(tx *types.Transaction) errordeprecated
- func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error
- func (pool *TxPool) AddRemotesSync(txs []*types.Transaction) []error
- func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
- func (pool *TxPool) ContentFrom(addr common.Address) (types.Transactions, types.Transactions)
- func (pool *TxPool) Get(hash common.Hash) *types.Transaction
- func (pool *TxPool) Has(hash common.Hash) bool
- func (pool *TxPool) Locals() []common.Address
- func (pool *TxPool) Nonce(addr common.Address) uint64
- func (pool *TxPool) Pending(enforceTips bool) map[common.Address]types.Transactions
- func (pool *TxPool) SetGasPrice(price *big.Int)
- func (pool *TxPool) Stats() (int, int)
- func (pool *TxPool) Status(hashes []common.Hash) []TxStatus
- func (pool *TxPool) Stop()
- func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription
- type TxStatus
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyKnown is returned if the transactions is already contained // within the pool. ErrAlreadyKnown = errors.New("already known") // ErrInvalidSender is returned if the transaction contains an invalid signature. ErrInvalidSender = errors.New("invalid sender") // ErrUnderpriced is returned if a transaction's gas price is below the minimum // configured for the transaction pool. ErrUnderpriced = errors.New("transaction underpriced") // ErrTxPoolOverflow is returned if the transaction pool is full and can't accept // another remote transaction. ErrTxPoolOverflow = errors.New("txpool is full") // 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") // 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 no one is able to specify a // transaction with a negative value. ErrNegativeValue = errors.New("negative value") // ErrOversizedData is returned if the input data of a transaction is greater // than some meaningful limit a user might use. This is not a consensus error // making the transaction invalid, rather a DOS protection. ErrOversizedData = errors.New("oversized data") // ErrFutureReplacePending is returned if a future transaction replaces a pending // transaction. Future transactions should only be able to replace other future transactions. ErrFutureReplacePending = errors.New("future transaction tries to replace pending") // ErrOverdraft is returned if a transaction would cause the senders balance to go negative // thus invalidating a potential large number of transactions. ErrOverdraft = errors.New("transaction would cause overdraft") )
var DefaultConfig = Config{ Journal: "transactions.rlp", Rejournal: time.Hour, PriceLimit: 1, PriceBump: 10, AccountSlots: 16, GlobalSlots: 4096 + 1024, AccountQueue: 64, GlobalQueue: 1024, Lifetime: 3 * time.Hour, }
DefaultConfig contains the default configurations for the transaction pool.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Locals []common.Address // Addresses that should be treated by default as local NoLocals bool // Whether local transaction handling should be disabled Journal string // Journal of local transactions to survive node restarts Rejournal time.Duration // Time interval to regenerate the local transaction journal PriceLimit uint64 // Minimum gas price to enforce for acceptance into the pool PriceBump uint64 // Minimum price bump percentage to replace an already existing transaction (nonce) AccountSlots uint64 // Number of executable transaction slots guaranteed per account GlobalSlots uint64 // Maximum number of executable transaction slots for all accounts AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts Lifetime time.Duration // Maximum amount of time non-executable transaction are queued }
Config are the configuration parameters of the transaction pool.
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool contains all currently known transactions. Transactions enter the pool when they are received from the network or submitted locally. They exit the pool when they are included in the blockchain.
The pool separates processable transactions (which can be applied to the current state) and future transactions. Transactions move between those two states over time as they are received and processed.
func NewTxPool ¶
func NewTxPool(config Config, chainconfig *params.ChainConfig, chain blockChain) *TxPool
NewTxPool creates a new transaction pool to gather, sort and filter inbound transactions from the network.
func (*TxPool) AddLocal ¶
func (pool *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 (pool *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 (pool *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 (pool *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) AddRemotesSync ¶
func (pool *TxPool) AddRemotesSync(txs []*types.Transaction) []error
This is like AddRemotes, but waits for pool reorganization. Tests use this method.
func (*TxPool) Content ¶
func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
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) ContentFrom ¶
func (pool *TxPool) ContentFrom(addr common.Address) (types.Transactions, types.Transactions)
ContentFrom retrieves the data content of the transaction pool, returning the pending as well as queued transactions of this address, grouped by nonce.
func (*TxPool) Get ¶
func (pool *TxPool) Get(hash common.Hash) *types.Transaction
Get returns a transaction if it is contained in the pool and nil otherwise.
func (*TxPool) Has ¶
Has returns an indicator whether txpool has a transaction cached with the given hash.
func (*TxPool) Nonce ¶
Nonce returns the next nonce of an account, with all transactions executable by the pool already applied on top.
func (*TxPool) Pending ¶
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.
func (*TxPool) SetGasPrice ¶
SetGasPrice updates the minimum price required by the transaction pool for a new transaction, and drops all transactions below this threshold.
func (*TxPool) Stats ¶
Stats retrieves the current pool stats, namely the number of pending and the number of queued (non-executable) transactions.
func (*TxPool) Status ¶
Status returns the status (unknown/pending/queued) of a batch of transactions identified by their hashes.
func (*TxPool) SubscribeNewTxsEvent ¶
func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription
SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending event to the given channel.