Documentation ¶
Index ¶
- Variables
- func IntrinsicGas(data []byte, tp types.TxType, contractCreation bool) (uint64, error)
- func TxDifference(a, b types.Transactions) types.Transactions
- type Config
- type TxPool
- func (tp *TxPool) Actions() []*types.Action
- func (tp *TxPool) AddAction(a *types.Action)
- func (tp *TxPool) AddTx(tx *types.Transaction) error
- func (tp *TxPool) AddTxs(txs []*types.Transaction) []error
- func (tp *TxPool) AddTxsChan(txs types.Transactions) bool
- func (tp *TxPool) Content() (map[utils.Address]types.Transactions, map[utils.Address]types.Transactions)
- func (tp *TxPool) GasPrice() *big.Int
- func (tp *TxPool) Get(hash utils.Hash) *types.Transaction
- func (tp *TxPool) Pending() (map[utils.Address]types.Transactions, error)
- func (tp *TxPool) SetGasPrice(price *big.Int)
- func (tp *TxPool) State() *state.ManagedState
- func (tp *TxPool) Stats() (int, int)
- func (tp *TxPool) Status(hashes []utils.Hash) []TxStatus
- func (tp *TxPool) Stop()
- func (tp *TxPool) SubscribeNewTxsEvent(ch chan<- feed.NewTxsEvent) feed.Subscription
- type TxStatus
Constants ¶
This section is empty.
Variables ¶
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") // ErrInsufficientFunds is returned if the total cost of executing a transaction // is higher than the balance of the user's account. ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") // ErrInsufficientLockedFunds is returned if the value of executing a transaction // is higher than the balance of the user's locked account. ErrInsufficientLockedFunds = errors.New("insufficient locked funds for value") // ErrInsufficientFeeFunds is returned if the fee of executing a transaction // is higher than the balance of the user's account. ErrInsufficientFeeFunds = errors.New("insufficient fee funds for gas * price") // 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") // 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") )
var DefaultTxPoolConfig = Config{ PriceLimit: 1, PriceBump: 10, AccountSlots: 16, GlobalSlots: 4096, AccountQueue: 64, GlobalQueue: 1024, TimeoutDuration: 3 * time.Hour, }
DefaultTxPoolConfig contains the default configurations for the transaction pool.
Functions ¶
func IntrinsicGas ¶
IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
func TxDifference ¶
func TxDifference(a, b types.Transactions) types.Transactions
TxDifference returns a new set which is the difference between a and b.
Types ¶
type Config ¶
type Config struct { PriceLimit uint64 `mapstructure:"txpool-pricelimit"` PriceBump uint64 `mapstructure:"txpool-pricebump"` AccountSlots uint64 `mapstructure:"txpool-accountslots"` GlobalSlots uint64 `mapstructure:"txpool-globalslots"` AccountQueue uint64 `mapstructure:"txpool-accountqueue"` GlobalQueue uint64 `mapstructure:"txpool-globalqueue"` TimeoutDuration time.Duration `mapstructure:"txpool-timeout"` }
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.
func New ¶
func New(config *Config, chainconfig *params.ChainConfig, chain blockChainHelper) *TxPool
New creates a new transaction pool to gather, sort and filter inbound transactions from the network.
func (*TxPool) AddTxsChan ¶
func (tp *TxPool) AddTxsChan(txs types.Transactions) bool
func (*TxPool) Content ¶
func (tp *TxPool) Content() (map[utils.Address]types.Transactions, map[utils.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) Get ¶
func (tp *TxPool) Get(hash utils.Hash) *types.Transaction
Get returns a transaction if it is contained in the pool and nil otherwise.
func (*TxPool) Pending ¶
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 ¶
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() *state.ManagedState
State returns the virtual managed state of the transaction tp.
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 (tp *TxPool) SubscribeNewTxsEvent(ch chan<- feed.NewTxsEvent) feed.Subscription
SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending event to the given channel.