txpool

package
v3.0.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: LGPL-3.0 Imports: 16 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 DeferServer added in v1.1.0

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

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

func NewDeferServer added in v1.1.0

func NewDeferServer(txpool *TxPImpl) (*DeferServer, error)

NewDeferServer returns a new DeferServer instance.

func (*DeferServer) DelDeferTx added in v1.1.0

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 added in v1.1.0

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

DumpDeferTx dumps all defer transactions for debug.

func (*DeferServer) Start added in v1.1.0

func (d *DeferServer) Start() error

Start starts the defer server.

func (*DeferServer) Stop added in v1.1.0

func (d *DeferServer) Stop()

Stop stops the defer server.

func (*DeferServer) StoreDeferTx added in v1.1.0

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 ...
	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, p2pService p2p.Service) (*TxPImpl, error)

NewTxPoolImpl returns a default TxPImpl instance.

func (*TxPImpl) AddDefertx added in v1.1.0

func (pool *TxPImpl) AddDefertx(txHash []byte) error

AddDefertx adds defer transaction.

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

AddTx add the transaction

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

ExistTxs determine if the transaction exists

func (*TxPImpl) GetFromChain added in v1.1.0

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

GetFromChain gets transaction from longest chain.

func (*TxPImpl) GetFromPending added in v1.1.0

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

GetFromPending gets transaction from pending list.

func (*TxPImpl) PendingTx added in v1.1.0

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

PendingTx is return pendingTx

func (*TxPImpl) Start

func (pool *TxPImpl) Start() error

Start starts the jobs.

func (*TxPImpl) Stop

func (pool *TxPImpl) Stop()

Stop stops all the jobs.

type TxPool

type TxPool interface {
	Start() error
	Stop()
	AddTx(tx *tx.Tx) 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) FRet
	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