mempool

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTestChainHeight = uint64(1)
	DefaultTestBatchSize   = uint64(4)
	DefaultTestTxSetSize   = uint64(1)
)
View Source
const (
	DefaultPoolSize    = 50000
	DefaultTxCacheSize = 10000
	DefaultBatchSize   = 500
	DefaultTxSetSize   = 10
	DefaultTxSetTick   = 100 * time.Millisecond
)

Variables

View Source
var (
	InterchainContractAddr = types.NewAddressByStr("000000000000000000000000000000000000000a")
)

Functions

This section is empty.

Types

type ChainState added in v1.4.0

type ChainState struct {
	Height     uint64
	BlockHash  *types.Hash
	TxHashList []*types.Hash
}

type Config

type Config struct {
	ID                 uint64
	BatchSize          uint64
	PoolSize           uint64
	IsTimed            bool
	BlockTimeout       time.Duration
	RebroadcastTimeout time.Duration
	TxSliceSize        uint64
	TxSliceTimeout     time.Duration
	ChainHeight        uint64
	Logger             logrus.FieldLogger
	StoragePath        string // db for persist mem pool meta data
	GetAccountNonce    GetAccountNonceFunc
}

type External added in v1.4.0

type External interface {

	// GetPendingNonceByAccount will return the latest pending nonce of a given account
	GetPendingNonceByAccount(account string) uint64

	GetPendingTransactions(max int) []pb.Transaction

	GetTransaction(hash *types.Hash) pb.Transaction

	// IsPoolFull check if memPool has exceeded the limited txSize.
	IsPoolFull() bool
}

External is a concurrent and safe interface, which can be called by api module directly.

type GetAccountNonceFunc added in v1.6.1

type GetAccountNonceFunc func(address *types.Address) uint64

type MemPool

type MemPool interface {
	// ProcessTransactions process transaction from api and other vp nodes.
	ProcessTransactions(txs []pb.Transaction, isLeader, isLocal bool) *raftproto.RequestBatch

	// GenerateBlock generate a block
	GenerateBlock() *raftproto.RequestBatch

	// CommitTransactions Remove removes the committed transactions from mempool
	CommitTransactions(state *ChainState)

	// HasPendingRequest checks if there is non-batched tx(s) in mempool pool or not
	HasPendingRequest() bool

	SetBatchSeqNo(batchSeq uint64)

	GetTimeoutTransactions(rebroadcastDuration time.Duration) [][]pb.Transaction

	// RemoveAliveTimeoutTxs get the remained local txs in timeoutIndex and removeTxs in memPool by tolerance time.
	RemoveAliveTimeoutTxs(removeDuration time.Duration) uint64

	SubscribeTxEvent(chan<- pb.Transactions) event.Subscription

	External
}

func NewMempool

func NewMempool(config *Config) (MemPool, error)

NewMempool return the mempool instance.

type TxCache

type TxCache struct {
	TxSetC  chan *pb.Transactions
	RecvTxC chan pb.Transaction
	TxRespC chan *TxWithResp
	// contains filtered or unexported fields
}

func NewTxCache added in v1.4.0

func NewTxCache(txSliceTimeout time.Duration, txSetSize uint64, logger logrus.FieldLogger) *TxCache

func (*TxCache) IsFull

func (tc *TxCache) IsFull() bool

func (*TxCache) ListenEvent added in v1.4.0

func (tc *TxCache) ListenEvent(ctx context.Context)

type TxWithResp added in v1.9.0

type TxWithResp struct {
	Tx pb.Transaction
	Ch chan bool
}

Jump to

Keyboard shortcuts

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