pool

package
v0.0.0-...-0c41aae Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonceSortedTxsEmpty = errors.New("Empty NonceSortedTxs")
	ErrNonceOutofRange     = errors.New("nonce is not in range")
)
View Source
var (
	ErrDuplicatedTx      = errors.New("duplicate transaction check failed")
	ErrRejectLowPriority = errors.New("txpool full, rejecting transaction with low priority")
)

Functions

This section is empty.

Types

type NonceSortedTxs

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

NonceSortedTxs store the txns that can be add into blockchain. The txns are sorted by nonce in Increasing order.

func NewNonceSortedTxs

func NewNonceSortedTxs(acc common.Uint160, cap int) *NonceSortedTxs

NewNonceSortedTxs return a new NonceSortedTxs instance

func (*NonceSortedTxs) CleanIfEmpty

func (nst *NonceSortedTxs) CleanIfEmpty() (isEmpty bool)

func (*NonceSortedTxs) Drop

func (nst *NonceSortedTxs) Drop(hashToDrop common.Uint256) (*transaction.Transaction, bool, error)

func (*NonceSortedTxs) Dump

func (nst *NonceSortedTxs) Dump()

func (*NonceSortedTxs) Empty

func (nst *NonceSortedTxs) Empty() bool

func (*NonceSortedTxs) ExistTx

func (nst *NonceSortedTxs) ExistTx(hash common.Uint256) bool

func (*NonceSortedTxs) Full

func (nst *NonceSortedTxs) Full() bool

func (*NonceSortedTxs) GetAllTransactions

func (nst *NonceSortedTxs) GetAllTransactions() []*transaction.Transaction

func (*NonceSortedTxs) GetByNonce

func (nst *NonceSortedTxs) GetByNonce(nonce uint64) (*transaction.Transaction, error)

func (*NonceSortedTxs) GetLatestNonce

func (nst *NonceSortedTxs) GetLatestNonce() (uint64, error)

func (*NonceSortedTxs) GetLatestTxn

func (nst *NonceSortedTxs) GetLatestTxn() (*transaction.Transaction, error)

func (*NonceSortedTxs) Len

func (nst *NonceSortedTxs) Len() int

func (*NonceSortedTxs) PopN

func (nst *NonceSortedTxs) PopN(n uint16) ([]*transaction.Transaction, error)

func (*NonceSortedTxs) Push

func (*NonceSortedTxs) Replace

func (nst *NonceSortedTxs) Replace(tx *transaction.Transaction) error

func (*NonceSortedTxs) Seek

func (nst *NonceSortedTxs) Seek() (*transaction.Transaction, error)

type TxPooler

type TxPooler interface {
	GetTxnByCount(num int) (map[Uint256]*transaction.Transaction, error)
	GetTransaction(hash Uint256) *transaction.Transaction
	AppendTxnPool(txn *transaction.Transaction) error
	CleanSubmittedTransactions(txns []*transaction.Transaction) error
}

type TxnPool

type TxnPool struct {
	TxLists        sync.Map // NonceSortedTxs instance to store user's account.
	TxMap          sync.Map
	TxShortHashMap sync.Map
	NanoPayTxs     sync.Map // tx with nano pay type.

	sync.RWMutex
	// contains filtered or unexported fields
}

TxnPool is a list of txns that need to by add to ledger sent by user.

func NewTxPool

func NewTxPool() *TxnPool

func (*TxnPool) AppendTxnPool

func (tp *TxnPool) AppendTxnPool(txn *transaction.Transaction) error

func (*TxnPool) CleanBlockValidationState

func (tp *TxnPool) CleanBlockValidationState(txns []*transaction.Transaction) error

func (*TxnPool) CleanSubmittedTransactions

func (tp *TxnPool) CleanSubmittedTransactions(txns []*transaction.Transaction) error

func (*TxnPool) DropTxns

func (tp *TxnPool) DropTxns()

func (*TxnPool) GetAddressList

func (tp *TxnPool) GetAddressList() map[common.Uint160]int

func (*TxnPool) GetAllTransactionLists

func (tp *TxnPool) GetAllTransactionLists() map[common.Uint160][]*transaction.Transaction

func (*TxnPool) GetAllTransactions

func (tp *TxnPool) GetAllTransactions() []*transaction.Transaction

func (*TxnPool) GetAllTransactionsBySender

func (tp *TxnPool) GetAllTransactionsBySender(programHash common.Uint160) []*transaction.Transaction

func (*TxnPool) GetNonceByTxnPool

func (tp *TxnPool) GetNonceByTxnPool(addr common.Uint160) (uint64, error)

func (*TxnPool) GetSubscribers

func (tp *TxnPool) GetSubscribers(topic string) []string

func (*TxnPool) GetSubscribersWithMeta

func (tp *TxnPool) GetSubscribersWithMeta(topic string) map[string]string

func (*TxnPool) GetTransaction

func (tp *TxnPool) GetTransaction(hash common.Uint256) *transaction.Transaction

func (*TxnPool) GetTxnByCount

func (tp *TxnPool) GetTxnByCount(num int) (map[common.Uint256]*transaction.Transaction, error)

func (*TxnPool) GetTxnByHash

func (tp *TxnPool) GetTxnByHash(hash common.Uint256) *transaction.Transaction

func (*TxnPool) GetTxnByShortHash

func (tp *TxnPool) GetTxnByShortHash(shortHash []byte) *transaction.Transaction

Jump to

Keyboard shortcuts

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