Documentation ¶
Index ¶
- Variables
- func IntrinsicGas(Extra []byte, inputs, outputs []interface{}) (uint64, error)
- func TxDifference(a, b types.Transactions) types.Transactions
- type ChainHeadEvent
- type Config
- type NewTxsEvent
- type TxPool
- func (tp *TxPool) AddLocal(tx *types.Transaction) error
- func (tp *TxPool) AddLocals(txs []*types.Transaction) []error
- func (tp *TxPool) AddRemote(tx *types.Transaction) error
- func (tp *TxPool) AddRemotes(txs []*types.Transaction) []error
- func (tp *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
- func (tp *TxPool) GasPrice() *big.Int
- func (tp *TxPool) Get(hash common.Hash) *types.Transaction
- func (tp *TxPool) Pending() (map[common.Address]types.Transactions, error)
- func (tp *TxPool) SetGasPrice(price *big.Int)
- func (tp *TxPool) State() *asset.Asset
- func (tp *TxPool) Stats() (int, int)
- func (tp *TxPool) Status(hashes []common.Hash) []TxStatus
- func (tp *TxPool) Stop()
- func (tp *TxPool) SubscribeNewTxsEvent(ch chan<- 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") // 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 SenderCacher = newTxSenderCacher(runtime.NumCPU())
senderCacher is a concurrent tranaction sender recoverer anc cacher.
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 ChainHeadEvent ¶
type Config ¶
type Config struct { 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 // Minimum 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 NewTxsEvent ¶
type NewTxsEvent struct{ Txs []*types.Transaction }
NewTxsEvent is posted when a batch of transactions enter 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, 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 transaction into the pool if it is valid, marking the sender as a local one in the mean time, ensuring it goes around the local pricing constraints.
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 in the mean time, ensuring they go around the local pricing constraints.
func (*TxPool) AddRemote ¶
func (tp *TxPool) AddRemote(tx *types.Transaction) error
AddRemote enqueues a single transaction into the pool if it is valid. If the sender is not among the locally tracked ones, full pricing constraints will apply.
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.
func (*TxPool) Content ¶
func (tp *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) 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 ¶
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) 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<- NewTxsEvent) feed.Subscription
SubscribeNewTxsEvent registers a subscription of NewTxsEvent and starts sending feed to the given channel.