txpool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Expiration is the transaction expiration
	Expiration = int64(90 * time.Second)
)

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 TAddTx

type TAddTx uint

TAddTx add the return value of the tx

const (
	// Success ...
	Success TAddTx = iota
	// TimeError ...
	TimeError
	// VerifyError ...
	VerifyError
	// DupError ...
	DupError
	// GasPriceError ...
	GasPriceError
	// CacheFullError ...
	CacheFullError
)

type TxPImpl

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

TxPImpl defines all the API of txpool package.

func NewTxPoolImpl

func NewTxPoolImpl(global global.BaseVariable, blockCache blockcache.BlockCache, p2ps p2p.Service) (*TxPImpl, error)

NewTxPoolImpl returns a default TxPImpl instance.

func (*TxPImpl) AddLinkedNode

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

AddLinkedNode add the block

func (*TxPImpl) AddTx

func (pool *TxPImpl) AddTx(t *tx.Tx) TAddTx

AddTx add the transaction

func (*TxPImpl) CheckTxs

func (pool *TxPImpl) CheckTxs(txs []*tx.Tx, chainBlock *block.Block) (*tx.Tx, error)

CheckTxs check txs

func (*TxPImpl) DelTx

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

DelTx del the transaction

func (*TxPImpl) DelTxList

func (pool *TxPImpl) DelTxList(delList []*tx.Tx)

DelTxList deletes the tx list in txpool.

func (*TxPImpl) ExistTxs

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

ExistTxs determine if the transaction exists

func (*TxPImpl) Lock

func (pool *TxPImpl) Lock()

Lock lock the txpool

func (*TxPImpl) PendingTxs

func (pool *TxPImpl) PendingTxs(maxCnt int) (TxsList, *blockcache.BlockCacheNode, error)

PendingTxs get the pending transactions

func (*TxPImpl) Release

func (pool *TxPImpl) Release()

Release release the txpool

func (*TxPImpl) Start

func (pool *TxPImpl) Start() error

Start starts the jobs.

func (*TxPImpl) Stop

func (pool *TxPImpl) Stop()

Stop stops all the jobs.

func (*TxPImpl) TxIterator

func (pool *TxPImpl) TxIterator() (*Iterator, *blockcache.BlockCacheNode)

TxIterator ...

func (*TxPImpl) TxTimeOut

func (pool *TxPImpl) TxTimeOut(tx *tx.Tx) bool

TxTimeOut time to verify the tx

type TxPool

type TxPool interface {
	Start() error
	Stop()
	AddLinkedNode(linkedNode *blockcache.BlockCacheNode, headNode *blockcache.BlockCacheNode) error
	AddTx(tx *tx.Tx) TAddTx
	DelTx(hash []byte) error
	DelTxList(delList []*tx.Tx)
	TxIterator() (*Iterator, *blockcache.BlockCacheNode)
	PendingTxs(maxCnt int) (TxsList, *blockcache.BlockCacheNode, error)
	ExistTxs(hash []byte, chainBlock *block.Block) (FRet, error)
	CheckTxs(txs []*tx.Tx, chainBlock *block.Block) (*tx.Tx, error)
	Lock()
	Release()
	TxTimeOut(tx *tx.Tx) bool
}

TxPool defines all the API of txpool package.

type TxsList

type TxsList []*tx.Tx

TxsList tx sort

func (TxsList) Len

func (s TxsList) Len() int

Len ...

func (TxsList) Less

func (s TxsList) Less(i, j int) bool

Less ...

func (*TxsList) Push

func (s *TxsList) Push(x *tx.Tx)

Push ...

func (TxsList) Swap

func (s TxsList) Swap(i, j int)

Swap ...

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