txpool

package
v3.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDupPendingTx = errors.New("tx exists in pending")
	ErrDupChainTx   = errors.New("tx exists in chain")
	ErrCacheFull    = errors.New("txpool is full")
	ErrTxNotFound   = errors.New("tx not found")
)

Values.

Functions

This section is empty.

Types

type FRet

type FRet uint

FRet find the return value of the tx

const (
	// NotFound ...
	NotFound FRet = iota
	// FoundPending ...
	FoundPending
	// FoundChain ...
	FoundChain
)

type Iterator

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

Iterator This is the iterator

func (*Iterator) Next

func (iter *Iterator) Next() (*tx.Tx, bool)

Next next the tx

type SortedTxMap

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

SortedTxMap is a red black tree of tx.

func NewSortedTxMap

func NewSortedTxMap() *SortedTxMap

NewSortedTxMap returns a new SortedTxMap instance.

func (*SortedTxMap) Add

func (st *SortedTxMap) Add(tx *tx.Tx)

Add adds a tx in SortedTxMap.

func (*SortedTxMap) Del

func (st *SortedTxMap) Del(hash []byte)

Del deletes a tx in SortedTxMap.

func (*SortedTxMap) Get

func (st *SortedTxMap) Get(hash []byte) *tx.Tx

Get returns a tx of hash.

func (*SortedTxMap) Iter

func (st *SortedTxMap) Iter() *Iterator

Iter returns the iterator of SortedTxMap.

func (*SortedTxMap) Size

func (st *SortedTxMap) Size() int

Size returns the size of SortedTxMap.

type TxPImpl

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

TxPImpl defines all the API of txpool package.

func NewTxPoolImpl

func NewTxPoolImpl(bChain block.Chain, blockCache blockcache.BlockCache) (*TxPImpl, error)

NewTxPoolImpl returns a default TxPImpl instance.

func (*TxPImpl) AddLinkedNode

func (pool *TxPImpl) AddLinkedNode(linkedNode *blockcache.BlockCacheNode) error

AddLinkedNode add the findBlock

func (*TxPImpl) AddTx

func (pool *TxPImpl) AddTx(t *tx.Tx, from string) error

AddTx add the transaction

func (*TxPImpl) Close

func (pool *TxPImpl) Close()

Close will close the tx pool.

func (*TxPImpl) DelTx

func (pool *TxPImpl) DelTx(hash []byte) error

DelTx del the transaction

func (*TxPImpl) ExistTxs

func (pool *TxPImpl) ExistTxs(hash []byte, chainBlock *block.Block) bool

ExistTxs determine if the transaction exists

func (*TxPImpl) GetFromChain

func (pool *TxPImpl) GetFromChain(hash []byte) (*tx.Tx, *tx.TxReceipt, error)

GetFromChain gets transaction from longest chain.

func (*TxPImpl) GetFromPending

func (pool *TxPImpl) GetFromPending(hash []byte) (*tx.Tx, error)

GetFromPending gets transaction from pending list.

func (*TxPImpl) PendingTx

func (pool *TxPImpl) PendingTx() (*SortedTxMap, *blockcache.BlockCacheNode)

PendingTx is return pendingTx

type TxPool

type TxPool interface {
	Close()
	AddTx(tx *tx.Tx, from string) error
	DelTx(hash []byte) error
	GetFromPending(hash []byte) (*tx.Tx, error)
	PendingTx() (*SortedTxMap, *blockcache.BlockCacheNode)

	// TODO: The following interfaces need to be moved from txpool to chainbase.
	AddLinkedNode(linkedNode *blockcache.BlockCacheNode) error
	ExistTxs(hash []byte, chainBlock *block.Block) bool
	GetFromChain(hash []byte) (*tx.Tx, *tx.TxReceipt, error)
}

TxPool defines all the API of txpool package.

Directories

Path Synopsis
Package txpool_mock is a generated GoMock package.
Package txpool_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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