txpool

package
v0.0.0-...-4701ab3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: LGPL-3.0 Imports: 6 Imported by: 3

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

TransactionPool errors

Functions

This section is empty.

Types

type AccountTransaction

type AccountTransaction interface {
	Seq() uint64
	From() common.Address
}

AccountTransaction is an interface that defines common functions of account model based transactions

type PoolItem

type PoolItem struct {
	Transaction transaction.Transaction
	TxHash      hash.Hash256
	Signatures  []common.Signature
}

PoolItem represents the item of the queue

type SeqCache

type SeqCache interface {
	Seq(addr common.Address) uint64
}

SeqCache is an interface that defines the function that acquire the last sequence of the address

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 If the sequence of the account model based transaction is not reached to the next of the last sequence, it doens't poped

func NewTransactionPool

func NewTransactionPool() *TransactionPool

NewTransactionPool returns a TransactionPool

func (*TransactionPool) IsExist

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

IsExist checks that the transaction hash is inserted or not

func (*TransactionPool) Pop

func (tp *TransactionPool) Pop(SeqCache SeqCache) *PoolItem

Pop returns and removes the proper transaction

func (*TransactionPool) Push

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

func (*TransactionPool) Remove

func (tp *TransactionPool) Remove(TxHash hash.Hash256, t transaction.Transaction)

Remove deletes the target transaction from the queue If it is an account model based transaction, it will be sorted by the sequence in the address

func (*TransactionPool) Size

func (tp *TransactionPool) Size() int

Size returns the size of TxPool

func (*TransactionPool) UnsafePop

func (tp *TransactionPool) UnsafePop(SeqCache SeqCache) *PoolItem

UnsafePop returns and removes the proper transaction without mutex locking

type UTXOTransaction

type UTXOTransaction interface {
	VinIDs() []uint64
}

UTXOTransaction is an interface that defines common functions of utxo model based transactions

Jump to

Keyboard shortcuts

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