txprocessor

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 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")

	//ErrWrongTransactionAmount is returned if a transaction's amount is nil
	ErrWrongTransactionAmount = errors.New("transaction's Amount is wrong")

	//ErrUnderpriority is returned if a transaction's priority is below the minimum
	//configured for the transaction pool
	ErrUnderPriority = errors.New("transaction underpriority")

	ErrReplaceUnderpriority = errors.New("replacement transaction underpriority")

	// 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 value")

	// 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")
)
View Source
var DefaultTxPoolConfig = TxPoolConfig{
	Journal:   "transactions.msgp",
	Rejournal: time.Hour,

	NoLocals:     true,
	AccountSlots: 16,
	GlobalSlots:  65536,
	AccountQueue: 640,
	GlobalQueue:  10240,
	Priority:     0,
	Lifetime:     30 * time.Minute,
}

DefaultTxPoolConfig contains the default configurations for the transaction pool.

Functions

This section is empty.

Types

type Interpreter

type Interpreter interface {
	/*
		if a transaction want join in txpool , a priority we should have,
		what is the priority?it should determined by miner's config file.
	*/
	GetPriorityFromTransaction(tx *transaction.Transaction) *big.Int
	SetPriorityForTransaction(tx *transaction.Transaction)
}

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 TxPoolConfig, 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 *transaction.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

func (*TxPool) AddLocals

func (pool *TxPool) AddLocals(txs []*transaction.Transaction) []error

AddLocals enqueues a batch of transactions into the pool if they are valid

func (*TxPool) AddRemote

func (pool *TxPool) AddRemote(tx *transaction.Transaction) error

AddRemote enqueues a single transaction into the pool if it is valid.

func (*TxPool) AddRemotes

func (pool *TxPool) AddRemotes(txs []*transaction.Transaction) []error

AddRemotes enqueues a batch of transactions into the pool if they are valid.

func (*TxPool) Content

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 (pool *TxPool) Get(hash types.Hash) *transaction.Transaction

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

func (*TxPool) Pending

func (pool *TxPool) Pending() (map[types.Address]transaction.Transactions, 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) PriorityThreshold

func (pool *TxPool) PriorityThreshold() *big.Int

setPriority updates the minimum priority required by the transaction pool for a new transaction, and drops all transactions below this threshold

func (*TxPool) RemoveTxs

func (pool *TxPool) RemoveTxs(hashs []types.Hash)

func (*TxPool) SetPriorityThreshold

func (pool *TxPool) SetPriorityThreshold(priority *big.Int)

func (*TxPool) State

func (pool *TxPool) State() *state.ManagedState

State returns the virtual managed state of the transaction pool.

func (*TxPool) Stats

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

Stats retrieves the current pool stats, namely the number of pending and the number of queued (non-executable) transactions.

func (*TxPool) Status

func (pool *TxPool) Status(hashes []types.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()

Stop terminates the transaction pool.

func (*TxPool) SubscribeTxPreEvent

func (pool *TxPool) SubscribeTxPreEvent(ch chan<- core.TxPreEvent) event.Subscription

SubscribeTxPreEvent registers a subscription of TxPreEvent and starts sending event to the given channel.

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

	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
	Priority     uint64
	Lifetime     time.Duration // Maximum amount of time non-executable transaction are queued
}

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
	TxStatusIncluded
)

Jump to

Keyboard shortcuts

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