Documentation
¶
Index ¶
- Variables
- type Metrics
- type TxOrigin
- type TxPool
- func (t *TxPool) AddSigner(s signer)
- func (t *TxPool) AddTx(tx *types.Transaction) error
- func (t *TxPool) AddTxn(ctx context.Context, raw *proto.AddTxnReq) (*proto.AddTxnResp, error)
- func (t *TxPool) DecreaseAccountNonce(tx *types.Transaction)
- func (t *TxPool) Discard(slotsToRemove uint64, force bool) ([]*types.Transaction, bool)
- func (t *TxPool) EnableDev()
- func (t *TxPool) GetCapacity() (uint64, uint64)
- func (t *TxPool) GetNonce(addr types.Address) uint64
- func (t *TxPool) GetPendingTx(txHash types.Hash) (*types.Transaction, bool)
- func (t *TxPool) GetTxs(inclQueued bool) (map[types.Address]map[uint64]*types.Transaction, ...)
- func (t *TxPool) Length() uint64
- func (t *TxPool) NumAccountTxs(address types.Address) int
- func (t *TxPool) Pop() (*types.Transaction, func())
- func (t *TxPool) ProcessEvent(evnt *blockchain.Event)
- func (t *TxPool) ResetWithHeaders(headers ...*types.Header)
- func (t *TxPool) Status(ctx context.Context, req *empty.Empty) (*proto.TxnPoolStatusResp, error)
- func (t *TxPool) Subscribe(req *empty.Empty, stream proto.TxnPoolOperator_SubscribeServer) error
- func (t *TxPool) Underpriced(tx *types.Transaction) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrIntrinsicGas = errors.New("intrinsic gas too low") ErrNegativeValue = errors.New("negative value") ErrNonEncryptedTxn = errors.New("non-encrypted transaction") 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 is returned if size of a transction is greater than the specified limit ErrOversizedData = errors.New("oversized data") )
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
Metrics represents the txpool metrics
func GetPrometheusMetrics ¶
GetPrometheusMetrics return the txpool metrics instance
func NilMetrics ¶
func NilMetrics() *Metrics
NilMetrics will return the non operational txpool metrics
type TxPool ¶
type TxPool struct {
// Notification channel used so signal added transactions to the pool
NotifyCh chan struct{}
// Indicates which txpool operator commands should be implemented
proto.UnimplementedTxnPoolOperatorServer
// contains filtered or unexported fields
}
TxPool is module that handles pending transactions.
There are fundamentally 2 queues in the txpool module: - Account based transactions (accountQueues) - Global valid transactions, from any account (pendingQueue)
func NewTxPool ¶
func NewTxPool( logger hclog.Logger, sealing bool, locals []types.Address, noLocals bool, priceLimit uint64, maxSlots uint64, forks chain.ForksInTime, store store, grpcServer *grpc.Server, network *network.Server, metrics *Metrics, ) (*TxPool, error)
NewTxPool creates a new pool for transactions
func (*TxPool) AddTx ¶
func (t *TxPool) AddTx(tx *types.Transaction) error
AddTx adds a new transaction to the pool and broadcasts it if networking is enabled
func (*TxPool) DecreaseAccountNonce ¶
func (t *TxPool) DecreaseAccountNonce(tx *types.Transaction)
DecreaseAccountNonce resets the nonce attached to an account whenever a transaction produce an error which is not recoverable, meaning the transaction will be discarded.
Since any discarded transaction should not affect the world state, the nextNonce should be reset to the value it was set to before the transaction appeared.
func (*TxPool) GetCapacity ¶
GetCapacity returns the current number of slots occupied and the max slot limit
func (*TxPool) GetNonce ¶
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 ¶
GetPendingTx returns the transaction by hash in the TxPool (pending txn) [Thread-safe]
func (*TxPool) GetTxs ¶
func (t *TxPool) GetTxs(inclQueued bool) (map[types.Address]map[uint64]*types.Transaction, map[types.Address]map[uint64]*types.Transaction)
GetTxs gets pending and queued transactions
func (*TxPool) NumAccountTxs ¶
NumAccountTxs Returns the number of transactions in the account specific queue
func (*TxPool) Pop ¶
func (t *TxPool) Pop() (*types.Transaction, func())
Pop returns the max priced transaction from the valid transactions heap in txpool
func (*TxPool) ProcessEvent ¶
func (t *TxPool) ProcessEvent(evnt *blockchain.Event)
ProcessEvent processes the blockchain event and updates the txpool accordingly
func (*TxPool) ResetWithHeaders ¶ added in v0.1.0
ResetWithHeader does basic txpool housekeeping after a block write
func (*TxPool) Status ¶
Status implements the GRPC status endpoint. Returns the number of transactions in the pool
func (*TxPool) Subscribe ¶
Subscribe implements the operator endpoint. It subscribes to new events in the tx pool
func (*TxPool) Underpriced ¶
func (t *TxPool) Underpriced(tx *types.Transaction) bool
Underpriced checks whether given tx's price is less than any in remote transactions