Documentation ¶
Index ¶
- func NewBalanceComputation() (*balanceComputation, error)
- func NewBlockSizeComputation(marshalizer marshal.Marshalizer, blockSizeThrottler BlockSizeThrottler, ...) (*blockSizeComputation, error)
- func NewGasComputation(economicsFee process.FeeHandler, txTypeHandler process.TxTypeHandler) (*gasComputation, error)
- func NewRewardTxPreprocessor(rewardTxDataPool dataRetriever.ShardedDataCacherNotifier, ...) (*rewardTxPreprocessor, error)
- func NewSmartContractResultPreprocessor(scrDataPool dataRetriever.ShardedDataCacherNotifier, ...) (*smartContractResults, error)
- func NewTransactionPreprocessor(txDataPool dataRetriever.ShardedDataCacherNotifier, ...) (*transactions, error)
- func NewValidatorInfoPreprocessor(hasher hashing.Hasher, marshalizer marshal.Marshalizer) (*validatorInfoPreprocessor, error)
- func SortTransactionsBySenderAndNonce(transactions []*txcache.WrappedTransaction)
- type BalanceComputationHandler
- type BlockSizeComputationHandler
- type BlockSizeThrottler
- type BlockTracker
- type SortedTransactionsProvider
- type TxCache
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBalanceComputation ¶ added in v1.0.106
func NewBalanceComputation() (*balanceComputation, error)
NewBalanceComputation creates a new object which computes the addresses balances
func NewBlockSizeComputation ¶
func NewBlockSizeComputation( marshalizer marshal.Marshalizer, blockSizeThrottler BlockSizeThrottler, maxSize uint32, ) (*blockSizeComputation, error)
NewBlockSizeComputation creates a blockSizeComputation instance
func NewGasComputation ¶
func NewGasComputation( economicsFee process.FeeHandler, txTypeHandler process.TxTypeHandler, ) (*gasComputation, error)
NewGasComputation creates a new object which computes the gas consumption
func NewRewardTxPreprocessor ¶
func NewRewardTxPreprocessor( rewardTxDataPool dataRetriever.ShardedDataCacherNotifier, store dataRetriever.StorageService, hasher hashing.Hasher, marshalizer marshal.Marshalizer, rewardProcessor process.RewardTransactionProcessor, shardCoordinator sharding.Coordinator, accounts state.AccountsAdapter, onRequestRewardTransaction func(shardID uint32, txHashes [][]byte), gasHandler process.GasHandler, pubkeyConverter core.PubkeyConverter, blockSizeComputation BlockSizeComputationHandler, balanceComputation BalanceComputationHandler, ) (*rewardTxPreprocessor, error)
NewRewardTxPreprocessor creates a new reward transaction preprocessor object
func NewSmartContractResultPreprocessor ¶
func NewSmartContractResultPreprocessor( scrDataPool dataRetriever.ShardedDataCacherNotifier, store dataRetriever.StorageService, hasher hashing.Hasher, marshalizer marshal.Marshalizer, scrProcessor process.SmartContractResultProcessor, shardCoordinator sharding.Coordinator, accounts state.AccountsAdapter, onRequestSmartContractResult func(shardID uint32, txHashes [][]byte), gasHandler process.GasHandler, economicsFee process.FeeHandler, pubkeyConverter core.PubkeyConverter, blockSizeComputation BlockSizeComputationHandler, balanceComputation BalanceComputationHandler, ) (*smartContractResults, error)
NewSmartContractResultPreprocessor creates a new smartContractResult preprocessor object
func NewTransactionPreprocessor ¶
func NewTransactionPreprocessor( txDataPool dataRetriever.ShardedDataCacherNotifier, store dataRetriever.StorageService, hasher hashing.Hasher, marshalizer marshal.Marshalizer, txProcessor process.TransactionProcessor, shardCoordinator sharding.Coordinator, accounts state.AccountsAdapter, onRequestTransaction func(shardID uint32, txHashes [][]byte), economicsFee process.FeeHandler, gasHandler process.GasHandler, blockTracker BlockTracker, blockType block.Type, pubkeyConverter core.PubkeyConverter, blockSizeComputation BlockSizeComputationHandler, balanceComputation BalanceComputationHandler, ) (*transactions, error)
NewTransactionPreprocessor creates a new transaction preprocessor object
func NewValidatorInfoPreprocessor ¶
func NewValidatorInfoPreprocessor( hasher hashing.Hasher, marshalizer marshal.Marshalizer, ) (*validatorInfoPreprocessor, error)
NewValidatorInfoPreprocessor creates a new validatorInfo preprocessor object
func SortTransactionsBySenderAndNonce ¶
func SortTransactionsBySenderAndNonce(transactions []*txcache.WrappedTransaction)
SortTransactionsBySenderAndNonce sorts the provided transactions and hashes simultaneously
Example ¶
txs := []*txcache.WrappedTransaction{ {Tx: &transaction.Transaction{Nonce: 3, SndAddr: []byte("bbbb")}, TxHash: []byte("w")}, {Tx: &transaction.Transaction{Nonce: 1, SndAddr: []byte("aaaa")}, TxHash: []byte("x")}, {Tx: &transaction.Transaction{Nonce: 5, SndAddr: []byte("bbbb")}, TxHash: []byte("y")}, {Tx: &transaction.Transaction{Nonce: 2, SndAddr: []byte("aaaa")}, TxHash: []byte("z")}, {Tx: &transaction.Transaction{Nonce: 7, SndAddr: []byte("aabb")}, TxHash: []byte("t")}, {Tx: &transaction.Transaction{Nonce: 6, SndAddr: []byte("aabb")}, TxHash: []byte("a")}, {Tx: &transaction.Transaction{Nonce: 3, SndAddr: []byte("ffff")}, TxHash: []byte("b")}, {Tx: &transaction.Transaction{Nonce: 3, SndAddr: []byte("eeee")}, TxHash: []byte("c")}, } SortTransactionsBySenderAndNonce(txs) for _, item := range txs { fmt.Println(item.Tx.GetNonce(), string(item.Tx.GetSndAddr()), string(item.TxHash)) }
Output: 1 aaaa x 2 aaaa z 6 aabb a 7 aabb t 3 bbbb w 5 bbbb y 3 eeee c 3 ffff b
Types ¶
type BalanceComputationHandler ¶ added in v1.0.106
type BalanceComputationHandler interface { Init() SetBalanceToAddress(address []byte, value *big.Int) AddBalanceToAddress(address []byte, value *big.Int) bool SubBalanceFromAddress(address []byte, value *big.Int) bool IsAddressSet(address []byte) bool AddressHasEnoughBalance(address []byte, value *big.Int) bool IsInterfaceNil() bool }
BalanceComputationHandler defines the functionality for addresses balances computation, used in preventing executing too many debit transactions, after the proposer executed a credit transaction on the same account in the same block
type BlockSizeComputationHandler ¶
type BlockSizeComputationHandler interface { Init() AddNumMiniBlocks(numMiniBlocks int) AddNumTxs(numTxs int) IsMaxBlockSizeReached(numNewMiniBlocks int, numNewTxs int) bool IsMaxBlockSizeWithoutThrottleReached(numNewMiniBlocks int, numNewTxs int) bool IsInterfaceNil() bool }
BlockSizeComputationHandler defines the functionality for block size computation
type BlockSizeThrottler ¶
BlockSizeThrottler defines the functionality of adapting the node to the network speed/latency when it should send a block to its peers which should be received in a limited time frame
type BlockTracker ¶
BlockTracker defines the functionality for node to track the blocks which are received from network
type SortedTransactionsProvider ¶
type SortedTransactionsProvider interface { GetSortedTransactions() []*txcache.WrappedTransaction NotifyAccountNonce(accountKey []byte, nonce uint64) IsInterfaceNil() bool }
SortedTransactionsProvider defines the public API of the transactions cache