Documentation
¶
Index ¶
- func NewBlockSizeComputation(marshalizer marshal.Marshalizer) (*blockSizeComputation, error)
- func NewGasComputation(economicsFee process.FeeHandler) (*gasComputation, error)
- func NewRewardTxPreprocessor(rewardTxDataPool dataRetriever.ShardedDataCacherNotifier, ...) (*rewardTxPreprocessor, error)
- func NewSmartContractResultPreprocessor(scrDataPool dataRetriever.ShardedDataCacherNotifier, ...) (*smartContractResults, error)
- func NewTransactionPreprocessor(txDataPool dataRetriever.ShardedDataCacherNotifier, ...) (*transactions, error)
- func SortTransactionsBySenderAndNonce(transactions []*txcache.WrappedTransaction)
- type BlockSizeComputationHandler
- type BlockTracker
- type SortedTransactionsProvider
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBlockSizeComputation ¶
func NewBlockSizeComputation(marshalizer marshal.Marshalizer) (*blockSizeComputation, error)
NewBlockSizeComputation creates a blockSizeComputation instance
func NewGasComputation ¶
func NewGasComputation( economicsFee process.FeeHandler, ) (*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, onRequestRewardTransaction func(shardID uint32, txHashes [][]byte), gasHandler process.GasHandler, blockSizeComputation BlockSizeComputationHandler, ) (*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, blockSizeComputation BlockSizeComputationHandler, ) (*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, addressConverter state.AddressConverter, blockSizeComputation BlockSizeComputationHandler, ) (*transactions, error)
NewTransactionPreprocessor creates a new transaction 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 BlockSizeComputationHandler ¶
type BlockSizeComputationHandler interface {
Init()
AddNumMiniBlocks(numMiniBlocks int)
AddNumTxs(numTxs int)
IsMaxBlockSizeReached(numNewMiniBlocks int, numNewTxs int) bool
IsInterfaceNil() bool
}
BlockSizeComputationHandler defines the functionality for block size computation
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