tx_pool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: LGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTxPoolConfig = TxPoolConfig{

	NoLocals:  true,
	Journal:   "transaction.rlp",
	Rejournal: time.Hour,

	FeeBump: 1,

	AccountSlots: 1024,
	GlobalSlots:  1024 * 20,
	AccountQueue: 1024 * 100,
	GlobalQueue:  1024 * 100,

	Lifetime: 3 * time.Hour,
}

Functions

This section is empty.

Types

type BlockChain

type BlockChain interface {
	CurrentBlock() model.AbstractBlock
	GetBlockByNumber(number uint64) model.AbstractBlock
	StateAtByStateRoot(root common.Hash) (*state_processor.AccountStateDB, error)
}

type TxByNonce

type TxByNonce []model.AbstractTransaction

func (TxByNonce) Len

func (t TxByNonce) Len() int

func (TxByNonce) Less

func (t TxByNonce) Less(i, j int) bool

func (TxByNonce) Swap

func (t TxByNonce) Swap(i, j int)

type TxPool

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

func NewTxPool

func NewTxPool(config TxPoolConfig, chainConfig chain_config.ChainConfig, chain BlockChain) *TxPool

func (*TxPool) AbstractTxsCaching

func (pool *TxPool) AbstractTxsCaching(txs []model.AbstractTransaction)

func (*TxPool) AddLocal

func (pool *TxPool) AddLocal(tx model.AbstractTransaction) 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 (pool *TxPool) AddLocals(txs []model.AbstractTransaction) []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 (pool *TxPool) AddRemote(tx model.AbstractTransaction) 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 (pool *TxPool) AddRemotes(txs []model.AbstractTransaction) []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) ConvertPoolToMap

func (pool *TxPool) ConvertPoolToMap() map[common.Hash]model.AbstractTransaction

func (*TxPool) Get

func (pool *TxPool) Get(hash common.Hash) model.AbstractTransaction

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

func (*TxPool) GetTxsEstimator

func (pool *TxPool) GetTxsEstimator(broadcastBloom *iblt.Bloom) *iblt.HybridEstimator

Create local tx pool hybrid estimator

func (*TxPool) Pending

func (pool *TxPool) Pending() (map[common.Address][]model.AbstractTransaction, 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) Queueing

func (pool *TxPool) Queueing() (map[common.Address][]model.AbstractTransaction, error)

get all transactions in future queue

func (*TxPool) RemoveTxs

func (pool *TxPool) RemoveTxs(newBlock model.AbstractBlock)

func (*TxPool) RemoveTxsBatch

func (pool *TxPool) RemoveTxsBatch(txIds []common.Hash)

func (*TxPool) Reset

func (pool *TxPool) Reset(oldHead, newHead *model.Header)

func (*TxPool) Start

func (pool *TxPool) Start() error

func (*TxPool) Stats

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

first: pending, second: queued

func (*TxPool) Status

func (pool *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 (pool *TxPool) Stop()

func (*TxPool) TxsCaching

func (pool *TxPool) TxsCaching(txs []*model.Transaction)

type TxPoolConfig

type TxPoolConfig 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

	MinFee  *big.Int // Minimum fee to enforce for acceptance into the pool
	FeeBump uint64   // Minimum fee 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
}

TODO:cannot package multiple election transaction in one round TxPoolConfig are the configuration parameters of the transaction pool.

type TxStatus

type TxStatus uint

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

const (
	TxStatusUnknown TxStatus = iota
	TxStatusQueued
	TxStatusPending
)

Jump to

Keyboard shortcuts

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