txpool

package
v0.0.0-...-24e5678 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyQueue                = errors.New("empty queue")
	ErrNotAccountTransaction     = errors.New("not account transaction")
	ErrExistTransaction          = errors.New("exist transaction")
	ErrTransactionPoolOverflowed = errors.New("transaction pool overflowed")
	ErrPastSeq                   = errors.New("past seq")
	ErrTooFarSeq                 = errors.New("too far seq")
)

TransactionPool errors

Functions

This section is empty.

Types

type PoolItem

type PoolItem struct {
	TxHash      hash.Hash256
	Transaction *types.Transaction
	Signature   common.Signature
	Signer      common.Address
	Slot        uint32
}

PoolItem represents the item of the queue

func (*PoolItem) DKey

func (pi *PoolItem) DKey() interface{}

func (*PoolItem) DPriority

func (pi *PoolItem) DPriority() uint64

func (*PoolItem) Key

func (pi *PoolItem) Key() interface{}

func (*PoolItem) Priority

func (pi *PoolItem) Priority() uint64

type TransactionPool

type TransactionPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TransactionPool provides a transaction queue User can push transaction regardless of UTXO model based transactions or account model based transactions

func NewTransactionPool

func NewTransactionPool() *TransactionPool

NewTransactionPool returns a TransactionPool

func (*TransactionPool) Clean

func (tp *TransactionPool) Clean(currentSlot uint32) []*types.Transaction

Clean removes outdated slot queue

func (*TransactionPool) Dump

func (tp *TransactionPool) Dump() string

Dump do dump

func (*TransactionPool) GasLevel

func (tp *TransactionPool) GasLevel() (glv uint16)

Size returns the size of TxPool

func (*TransactionPool) Get

func (tp *TransactionPool) Get(TxHash hash.Hash256) *PoolItem

Get returns the pool item of the hash

func (*TransactionPool) IsExist

func (tp *TransactionPool) IsExist(TxHash hash.Hash256) bool

IsExist checks that the transaction hash is inserted or not

func (*TransactionPool) List

func (tp *TransactionPool) List() []*PoolItem

List return txpool list

func (*TransactionPool) Pop

func (tp *TransactionPool) Pop(currentSlot uint32) *PoolItem

Pop returns and removes the proper transaction

func (*TransactionPool) Push

func (tp *TransactionPool) Push(TxHash hash.Hash256, tx *types.Transaction, sig common.Signature, signer common.Address) error

Push inserts the transaction and signatures of it by base model An UTXO model based transaction will be handled by FIFO

func (*TransactionPool) Remove

func (tp *TransactionPool) Remove(TxHash hash.Hash256, tx *types.Transaction)

Remove deletes the target transaction from the queue

func (*TransactionPool) Size

func (tp *TransactionPool) Size() int

Size returns the size of TxPool

func (*TransactionPool) UnsafePop

func (tp *TransactionPool) UnsafePop(currentSlot uint32) *PoolItem

UnsafePop returns and removes the proper transaction without mutex locking

func (*TransactionPool) UnsafeSize

func (tp *TransactionPool) UnsafeSize() int

UnsafeSize returns the size of TxPool without mutex

Jump to

Keyboard shortcuts

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