Version: v3.6.0 Latest Latest

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

Go to latest
Published: Apr 16, 2021 License: LGPL-3.0 Imports: 14 Imported by: 0




This section is empty.


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



This section is empty.


type DeferServer

type DeferServer struct {
	// contains filtered or unexported fields

DeferServer manages defer transaction index and sends them to txpool on time.

func NewDeferServer

func NewDeferServer(txpool TxPool, bChain block.Chain) (*DeferServer, error)

NewDeferServer returns a new DeferServer instance.

func (*DeferServer) DelDeferTx

func (d *DeferServer) DelDeferTx(deferTx *tx.Tx) error

DelDeferTx deletes a tx in defer server.

func (*DeferServer) DelDeferTxByHash

func (d *DeferServer) DelDeferTxByHash(txHash []byte)

DelDeferTxByHash deletes a tx in defer server by referredTx hash.

func (*DeferServer) DumpDeferTx

func (d *DeferServer) DumpDeferTx() []*tx.Tx

DumpDeferTx dumps all defer transactions for debug.

func (*DeferServer) ProcessDelaytx

func (d *DeferServer) ProcessDelaytx(blk *block.Block)

ProcessDelaytx will process the delay tx.

func (*DeferServer) Start

func (d *DeferServer) Start() error

Start starts the defer server.

func (*DeferServer) Stop

func (d *DeferServer) Stop()

Stop stops the defer server.

func (*DeferServer) StoreDeferTx

func (d *DeferServer) StoreDeferTx(delayTx *tx.Tx)

StoreDeferTx stores a tx in defer server.

type FRet

type FRet uint

FRet find the return value of the tx

const (
	// NotFound ...
	NotFound FRet = iota
	// FoundPending ...
	// 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 {
	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.


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