txpool

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = TxPoolLogger{}

Global instant to use

Functions

This section is empty.

Types

type BeaconViewRetriever

type BeaconViewRetriever interface {
	GetAllCommitteeValidatorCandidate() (map[byte][]incognitokey.CommitteePublicKey, map[byte][]incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, error)
	GetAllCommitteeValidatorCandidateFlattenListFromDatabase() ([]string, error)
	GetAutoStakingList() map[string]bool
	GetBeaconFeatureStateDB() *statedb.StateDB
	GetBeaconRewardStateDB() *statedb.StateDB
	GetBeaconSlashStateDB() *statedb.StateDB
}

type BlockTxsVerifier

type BlockTxsVerifier interface {
	FullValidateTransactions(
		txP TxPool,
		sView interface{},
		bcView interface{},
		txs []metadata.Transaction,
	) (bool, error)
	ValidateBatchRangeProof([]metadata.Transaction) (bool, error)
}

type CoinsData

type CoinsData struct {
	TxHashByCoin  map[string]string
	CoinsByTxHash map[string][]string
	// contains filtered or unexported fields
}

type FeeEstimator

type FeeEstimator interface {
	RegisterBlock(block *types.ShardBlock) error
	EstimateFee(numBlocks uint64, tokenId *common.Hash) (uint64, error)
	GetLimitFeeForNativeToken() uint64
	GetMinFeePerTx() uint64
	GetSpecifiedFeeTx() uint64
	GetSpecifiedFeePerKBType2() uint64
	GetSpecifiedFeePerTxType2() uint64
}

type GetMempoolInfo

type GetMempoolInfo struct {
	Size          int
	Bytes         uint64
	Usage         uint64
	MaxMempool    uint64
	MempoolMinFee uint64
	MempoolMaxFee uint64
	ListTxs       []MempoolInfoTx
}

func (*GetMempoolInfo) GetBytes

func (info *GetMempoolInfo) GetBytes() uint64

func (*GetMempoolInfo) GetListTxs

func (info *GetMempoolInfo) GetListTxs() []MempoolInfoTx

func (*GetMempoolInfo) GetMaxMempool

func (info *GetMempoolInfo) GetMaxMempool() uint64

func (*GetMempoolInfo) GetMempoolMaxFee

func (info *GetMempoolInfo) GetMempoolMaxFee() uint64

func (*GetMempoolInfo) GetMempoolMinFee

func (info *GetMempoolInfo) GetMempoolMinFee() uint64

func (*GetMempoolInfo) GetSize

func (info *GetMempoolInfo) GetSize() int

func (*GetMempoolInfo) GetUsage

func (info *GetMempoolInfo) GetUsage() uint64

type GetMempoolInfoTx

type GetMempoolInfoTx struct {
	TxID     string
	LockTime int64
}

func (*GetMempoolInfoTx) GetLockTime

func (infoTx *GetMempoolInfoTx) GetLockTime() int64

func (*GetMempoolInfoTx) GetTxID

func (infoTx *GetMempoolInfoTx) GetTxID() string

type MempoolInfo

type MempoolInfo interface {
	GetSize() int
	GetBytes() uint64
	GetUsage() uint64
	GetMaxMempool() uint64
	GetMempoolMinFee() uint64
	GetMempoolMaxFee() uint64
	GetListTxs() []MempoolInfoTx
}

type MempoolInfoTx

type MempoolInfoTx interface {
	GetTxID() string
	GetLockTime() int64
}

type PoolManager

type PoolManager struct {
	ShardTxsPool []TxPool
	// contains filtered or unexported fields
}

func NewPoolManager

func NewPoolManager(
	activeShards int,
	ps *pubsub.PubSubManager,
	ttl time.Duration,
) (
	*PoolManager,
	error,
)

func (*PoolManager) FilterMemPoolOutcoinsToSpent

func (pm *PoolManager) FilterMemPoolOutcoinsToSpent(outCoins []privacy.PlainCoin, sID int) []privacy.PlainCoin

func (*PoolManager) GetMempoolInfo

func (pm *PoolManager) GetMempoolInfo() MempoolInfo

func (*PoolManager) GetShardTxsPool

func (pm *PoolManager) GetShardTxsPool(shardID byte) (TxPool, error)

func (*PoolManager) GetTransactionByHash

func (pm *PoolManager) GetTransactionByHash(txHash string) (metadata.Transaction, error)

func (*PoolManager) RemoveTransactionInPool

func (pm *PoolManager) RemoveTransactionInPool(txHash string)

func (*PoolManager) Start

func (pm *PoolManager) Start(relayShards []byte) error

type PrefetchInterface

type PrefetchInterface interface {
	context.Context
	DecreaseNumTXRemain()
	GetMaxTime() time.Duration
	GetMaxSize() uint64
	IsRunning() bool
	GetNumTxRemain() int64
}

type ShardViewRetriever

type ShardViewRetriever interface {
	GetEpoch() uint64
	GetBeaconHeight() uint64
	GetStakingTx() map[string]string
	ListShardPrivacyTokenAndPRV() []common.Hash
	GetShardRewardStateDB() *statedb.StateDB
	GetCopiedFeatureStateDB() *statedb.StateDB
}

type TxInfo

type TxInfo struct {
	Fee   uint64
	Size  uint64
	VTime time.Duration
}

type TxInfoDetail

type TxInfoDetail struct {
	Hash  string
	Fee   uint64
	Size  uint64
	VTime time.Duration
	Tx    metadata.Transaction
}

type TxPool

type TxPool interface {
	UpdateTxVerifier(tv TxVerifier)
	Start()
	Stop()
	GetInbox() chan metadata.Transaction
	IsRunning() bool
	RemoveTxs(txHashes []string)
	GetTxsTranferForNewBlock(
		cView metadata.ChainRetriever,
		sView metadata.ShardViewRetriever,
		bcView metadata.BeaconViewRetriever,
		ctx PrefetchInterface,
	) []metadata.Transaction
	FilterWithNewView(
		cView metadata.ChainRetriever,
		sView metadata.ShardViewRetriever,
		bcView metadata.BeaconViewRetriever,
	)
	CheckValidatedTxs(
		txs []metadata.Transaction,
	) (
		valid []metadata.Transaction,
		needValidate []metadata.Transaction,
	)
	CheckDoubleSpendWithCurMem(
		target metadata.Transaction,
	) (
		bool,
		bool,
		string,
		[]string,
	)

	RemoveTx(txHash string)
	// contains filtered or unexported methods
}

type TxPoolLogger

type TxPoolLogger struct {
	common.Logger
}

func (*TxPoolLogger) Init

func (self *TxPoolLogger) Init(inst common.Logger)

type TxPoolManager

type TxPoolManager interface {
	GetShardTxsPool(shardID byte) (TxPool, error)
	StartShardTxsPool(shardID byte) error
	StopShardTxsPool(shardID byte) error
}

type TxVerifier

type TxVerifier interface {
	ValidateWithoutChainstate(metadata.Transaction) (bool, error)
	ValidateWithChainState(
		tx metadata.Transaction,
		chainRetriever metadata.ChainRetriever,
		shardViewRetriever metadata.ShardViewRetriever,
		beaconViewRetriever metadata.BeaconViewRetriever,
		beaconHeight uint64,
	) (bool, error)
	FullValidateTransactions(
		chainRetriever metadata.ChainRetriever,
		shardViewRetriever metadata.ShardViewRetriever,
		beaconViewRetriever metadata.BeaconViewRetriever,
		txs []metadata.Transaction,
	) (bool, error)
	LoadCommitment(
		tx metadata.Transaction,
		shardViewRetriever metadata.ShardViewRetriever,
	) (bool, error)
	PrepareDataForTxs(
		validTxs []metadata.Transaction,
		newTxs []metadata.Transaction,
		shardViewRetriever metadata.ShardViewRetriever,
	) (bool, error)
	UpdateTransactionStateDB(
		newSDB *statedb.StateDB,
	)
	UpdateFeeEstimator(
		estimator FeeEstimator,
	)
}

type TxsData

type TxsData struct {
	TxByHash map[string]metadata.Transaction
	TxInfos  map[string]TxInfo
}

type TxsPool

type TxsPool struct {
	Verifier TxVerifier
	Data     TxsData
	Cacher   *cache.Cache
	Inbox    chan metadata.Transaction

	CData CoinsData
	// contains filtered or unexported fields
}

func NewTxsPool

func NewTxsPool(
	txVerifier TxVerifier,
	inbox chan metadata.Transaction,
	ttl time.Duration,
) *TxsPool

func (*TxsPool) CheckDoubleSpend

func (tp *TxsPool) CheckDoubleSpend(
	dataHelper map[[privacy.Ed25519KeySize]byte]struct {
		Index  uint
		Detail TxInfoDetail
	},
	tx metadata.Transaction,
	txs *[]metadata.Transaction,
) (
	bool,
	bool,
	TxInfo,
	map[uint]interface{},
)

func (*TxsPool) CheckDoubleSpendWithCurMem

func (tp *TxsPool) CheckDoubleSpendWithCurMem(target metadata.Transaction) (bool, bool, string, []string)

func (*TxsPool) CheckValidatedTxs

func (tp *TxsPool) CheckValidatedTxs(
	txs []metadata.Transaction,
) (
	valid []metadata.Transaction,
	needValidate []metadata.Transaction,
)

func (*TxsPool) FilterWithNewView

func (tp *TxsPool) FilterWithNewView(
	cView metadata.ChainRetriever,
	sView metadata.ShardViewRetriever,
	bcView metadata.BeaconViewRetriever,
)

func (*TxsPool) GetInbox

func (tp *TxsPool) GetInbox() chan metadata.Transaction

func (*TxsPool) GetTxsTranferForNewBlock

func (tp *TxsPool) GetTxsTranferForNewBlock(
	cView metadata.ChainRetriever,
	sView metadata.ShardViewRetriever,
	bcView metadata.BeaconViewRetriever,
	ctx PrefetchInterface,
) []metadata.Transaction

func (*TxsPool) IsRunning

func (tp *TxsPool) IsRunning() bool

func (*TxsPool) RemoveTx

func (tp *TxsPool) RemoveTx(txHash string)

func (*TxsPool) RemoveTxs

func (tp *TxsPool) RemoveTxs(txHashes []string)

func (*TxsPool) Start

func (tp *TxsPool) Start()

func (*TxsPool) Stop

func (tp *TxsPool) Stop()

func (*TxsPool) UpdateTxVerifier

func (tp *TxsPool) UpdateTxVerifier(tv TxVerifier)

func (*TxsPool) ValidateNewTx

func (tp *TxsPool) ValidateNewTx(tx metadata.Transaction) (bool, error, time.Duration)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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