Documentation
¶
Index ¶
- type ConfigDestinationMe
- type ConfigSourceMe
- type CrossTxCache
- func (cache *CrossTxCache) AddTx(tx *WrappedTransaction) (has, added bool)
- func (cache *CrossTxCache) ForEachTransaction(function ForEachTransaction)
- func (cache *CrossTxCache) Get(key []byte) (value interface{}, ok bool)
- func (cache *CrossTxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
- func (cache *CrossTxCache) GetTransactionsPoolForSender(_ string) []*WrappedTransaction
- func (cache *CrossTxCache) ImmunizeTxsAgainstEviction(keys [][]byte)
- func (cache *CrossTxCache) IsInterfaceNil() bool
- func (cache *CrossTxCache) Peek(key []byte) (value interface{}, ok bool)
- func (cache *CrossTxCache) RemoveTxByHash(txHash []byte) bool
- type DisabledCache
- func (cache *DisabledCache) AddTx(_ *WrappedTransaction) (ok bool, added bool)
- func (cache *DisabledCache) Clear()
- func (cache *DisabledCache) Close() error
- func (cache *DisabledCache) Diagnose(_ bool)
- func (cache *DisabledCache) ForEachTransaction(_ ForEachTransaction)
- func (cache *DisabledCache) Get(_ []byte) (value interface{}, ok bool)
- func (cache *DisabledCache) GetByTxHash(_ []byte) (*WrappedTransaction, bool)
- func (cache *DisabledCache) GetTransactionsPoolForSender(_ string) []*WrappedTransaction
- func (cache *DisabledCache) Has(_ []byte) bool
- func (cache *DisabledCache) HasOrAdd(_ []byte, _ interface{}, _ int) (has, added bool)
- func (cache *DisabledCache) ImmunizeTxsAgainstEviction(_ [][]byte)
- func (cache *DisabledCache) IsInterfaceNil() bool
- func (cache *DisabledCache) Keys() [][]byte
- func (cache *DisabledCache) Len() int
- func (cache *DisabledCache) MaxSize() int
- func (cache *DisabledCache) NumBytes() int
- func (cache *DisabledCache) Peek(_ []byte) (value interface{}, ok bool)
- func (cache *DisabledCache) Put(_ []byte, _ interface{}, _ int) (evicted bool)
- func (cache *DisabledCache) RegisterHandler(func(key []byte, value interface{}), string)
- func (cache *DisabledCache) Remove(_ []byte)
- func (cache *DisabledCache) RemoveTxByHash(_ []byte) bool
- func (cache *DisabledCache) SelectTransactions(uint64, int) ([]*WrappedTransaction, uint64)
- func (cache *DisabledCache) SizeInBytesContained() uint64
- func (cache *DisabledCache) UnRegisterHandler(string)
- type ForEachTransaction
- type MempoolHost
- type SelectionSession
- type TxCache
- func (cache *TxCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)
- func (cache *TxCache) Clear()
- func (cache *TxCache) Close() error
- func (cache *TxCache) CountSenders() uint64
- func (cache *TxCache) CountTx() uint64
- func (cache *TxCache) Diagnose(_ bool)
- func (cache *TxCache) ForEachTransaction(function ForEachTransaction)
- func (cache *TxCache) Get(key []byte) (value interface{}, ok bool)
- func (cache *TxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
- func (cache *TxCache) GetTransactionsPoolForSender(sender string) []*WrappedTransaction
- func (cache *TxCache) Has(key []byte) bool
- func (cache *TxCache) HasOrAdd(_ []byte, _ interface{}, _ int) (has, added bool)
- func (cache *TxCache) ImmunizeTxsAgainstEviction(_ [][]byte)
- func (cache *TxCache) IsInterfaceNil() bool
- func (cache *TxCache) Keys() [][]byte
- func (cache *TxCache) Len() int
- func (cache *TxCache) MaxSize() int
- func (cache *TxCache) NumBytes() int
- func (cache *TxCache) Peek(key []byte) (value interface{}, ok bool)
- func (cache *TxCache) Put(_ []byte, _ interface{}, _ int) (evicted bool)
- func (cache *TxCache) RegisterHandler(func(key []byte, value interface{}), string)
- func (cache *TxCache) Remove(key []byte)
- func (cache *TxCache) RemoveTxByHash(txHash []byte) bool
- func (cache *TxCache) SelectTransactions(session SelectionSession, gasRequested uint64, maxNum int, ...) ([]*WrappedTransaction, uint64)
- func (cache *TxCache) SizeInBytesContained() uint64
- func (cache *TxCache) UnRegisterHandler(string)
- type WrappedTransaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigDestinationMe ¶
type ConfigDestinationMe struct { Name string NumChunks uint32 MaxNumItems uint32 MaxNumBytes uint32 NumItemsToPreemptivelyEvict uint32 }
ConfigDestinationMe holds cache configuration
func (*ConfigDestinationMe) String ¶
func (config *ConfigDestinationMe) String() string
String returns a readable representation of the object
type ConfigSourceMe ¶
type ConfigSourceMe struct { Name string NumChunks uint32 EvictionEnabled bool NumBytesThreshold uint32 NumBytesPerSenderThreshold uint32 CountThreshold uint32 CountPerSenderThreshold uint32 NumItemsToPreemptivelyEvict uint32 }
ConfigSourceMe holds cache configuration
func (*ConfigSourceMe) String ¶
func (config *ConfigSourceMe) String() string
String returns a readable representation of the object
type CrossTxCache ¶
type CrossTxCache struct { *immunitycache.ImmunityCache // contains filtered or unexported fields }
CrossTxCache holds cross-shard transactions (where destination == me)
func NewCrossTxCache ¶
func NewCrossTxCache(config ConfigDestinationMe) (*CrossTxCache, error)
NewCrossTxCache creates a new transactions cache
func (*CrossTxCache) AddTx ¶
func (cache *CrossTxCache) AddTx(tx *WrappedTransaction) (has, added bool)
AddTx adds a transaction in the cache
func (*CrossTxCache) ForEachTransaction ¶
func (cache *CrossTxCache) ForEachTransaction(function ForEachTransaction)
ForEachTransaction iterates over the transactions in the cache
func (*CrossTxCache) Get ¶
func (cache *CrossTxCache) Get(key []byte) (value interface{}, ok bool)
Get returns the unwrapped payload of a TransactionWrapper Implemented for compatibility reasons (see txPoolsCleaner.go).
func (*CrossTxCache) GetByTxHash ¶
func (cache *CrossTxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
GetByTxHash gets the transaction by hash
func (*CrossTxCache) GetTransactionsPoolForSender ¶
func (cache *CrossTxCache) GetTransactionsPoolForSender(_ string) []*WrappedTransaction
GetTransactionsPoolForSender returns an empty slice, only to respect the interface CrossTxCache does not support transaction selection (not applicable, since transactions are already half-executed), thus does not handle nonces, nonce gaps etc.
func (*CrossTxCache) ImmunizeTxsAgainstEviction ¶
func (cache *CrossTxCache) ImmunizeTxsAgainstEviction(keys [][]byte)
ImmunizeTxsAgainstEviction marks items as non-evictable
func (*CrossTxCache) IsInterfaceNil ¶
func (cache *CrossTxCache) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*CrossTxCache) Peek ¶
func (cache *CrossTxCache) Peek(key []byte) (value interface{}, ok bool)
Peek returns the unwrapped payload of a TransactionWrapper Implemented for compatibility reasons (see transactions.go, common.go).
func (*CrossTxCache) RemoveTxByHash ¶
func (cache *CrossTxCache) RemoveTxByHash(txHash []byte) bool
RemoveTxByHash removes tx by hash
type DisabledCache ¶
type DisabledCache struct { }
DisabledCache represents a disabled cache
func NewDisabledCache ¶
func NewDisabledCache() *DisabledCache
NewDisabledCache creates a new disabled cache
func (*DisabledCache) AddTx ¶
func (cache *DisabledCache) AddTx(_ *WrappedTransaction) (ok bool, added bool)
AddTx does nothing
func (*DisabledCache) ForEachTransaction ¶
func (cache *DisabledCache) ForEachTransaction(_ ForEachTransaction)
ForEachTransaction does nothing
func (*DisabledCache) Get ¶
func (cache *DisabledCache) Get(_ []byte) (value interface{}, ok bool)
Get returns no transaction
func (*DisabledCache) GetByTxHash ¶
func (cache *DisabledCache) GetByTxHash(_ []byte) (*WrappedTransaction, bool)
GetByTxHash returns no transaction
func (*DisabledCache) GetTransactionsPoolForSender ¶
func (cache *DisabledCache) GetTransactionsPoolForSender(_ string) []*WrappedTransaction
GetTransactionsPoolForSender returns an empty slice
func (*DisabledCache) HasOrAdd ¶
func (cache *DisabledCache) HasOrAdd(_ []byte, _ interface{}, _ int) (has, added bool)
HasOrAdd returns false, does nothing
func (*DisabledCache) ImmunizeTxsAgainstEviction ¶
func (cache *DisabledCache) ImmunizeTxsAgainstEviction(_ [][]byte)
ImmunizeTxsAgainstEviction does nothing
func (*DisabledCache) IsInterfaceNil ¶
func (cache *DisabledCache) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*DisabledCache) Keys ¶
func (cache *DisabledCache) Keys() [][]byte
Keys returns an empty slice
func (*DisabledCache) Peek ¶
func (cache *DisabledCache) Peek(_ []byte) (value interface{}, ok bool)
Peek returns no transaction
func (*DisabledCache) Put ¶
func (cache *DisabledCache) Put(_ []byte, _ interface{}, _ int) (evicted bool)
Put does nothing
func (*DisabledCache) RegisterHandler ¶
func (cache *DisabledCache) RegisterHandler(func(key []byte, value interface{}), string)
RegisterHandler does nothing
func (*DisabledCache) RemoveTxByHash ¶
func (cache *DisabledCache) RemoveTxByHash(_ []byte) bool
RemoveTxByHash does nothing
func (*DisabledCache) SelectTransactions ¶
func (cache *DisabledCache) SelectTransactions(uint64, int) ([]*WrappedTransaction, uint64)
SelectTransactions returns an empty slice
func (*DisabledCache) SizeInBytesContained ¶
func (cache *DisabledCache) SizeInBytesContained() uint64
SizeInBytesContained returns 0
func (*DisabledCache) UnRegisterHandler ¶
func (cache *DisabledCache) UnRegisterHandler(string)
UnRegisterHandler does nothing
type ForEachTransaction ¶
type ForEachTransaction func(txHash []byte, value *WrappedTransaction)
ForEachTransaction is an iterator callback
type MempoolHost ¶
type MempoolHost interface { ComputeTxFee(tx data.TransactionWithFeeHandler) *big.Int GetTransferredValue(tx data.TransactionHandler) *big.Int IsInterfaceNil() bool }
MempoolHost provides blockchain information for mempool operations
type SelectionSession ¶
type SelectionSession interface { GetAccountState(accountKey []byte) (*types.AccountState, error) IsIncorrectlyGuarded(tx data.TransactionHandler) bool IsInterfaceNil() bool }
SelectionSession provides blockchain information for transaction selection
type TxCache ¶
type TxCache struct {
// contains filtered or unexported fields
}
TxCache represents a cache-like structure (it has a fixed capacity and implements an eviction mechanism) for holding transactions
func NewTxCache ¶
func NewTxCache(config ConfigSourceMe, host MempoolHost) (*TxCache, error)
NewTxCache creates a new transaction cache
func (*TxCache) AddTx ¶
func (cache *TxCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)
AddTx adds a transaction in the cache Eviction happens if maximum capacity is reached
func (*TxCache) CountSenders ¶
CountSenders gets the number of senders in the cache
func (*TxCache) Diagnose ¶
Diagnose checks the state of the cache for inconsistencies and displays a summary, senders and transactions.
func (*TxCache) ForEachTransaction ¶
func (cache *TxCache) ForEachTransaction(function ForEachTransaction)
ForEachTransaction iterates over the transactions in the cache
func (*TxCache) Get ¶
Get gets a transaction (unwrapped) by hash Implemented for compatibility reasons (see txPoolsCleaner.go).
func (*TxCache) GetByTxHash ¶
func (cache *TxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
GetByTxHash gets the transaction by hash
func (*TxCache) GetTransactionsPoolForSender ¶
func (cache *TxCache) GetTransactionsPoolForSender(sender string) []*WrappedTransaction
GetTransactionsPoolForSender returns the list of transaction hashes for the sender
func (*TxCache) ImmunizeTxsAgainstEviction ¶
ImmunizeTxsAgainstEviction does nothing for this type of cache
func (*TxCache) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*TxCache) MaxSize ¶
MaxSize returns the maximum number of transactions that can be stored in the cache. See: https://github.com/TerraDharitri/drt-go-chain/blob/v1.8.4/dataRetriever/txpool/shardedTxPool.go#L55
func (*TxCache) Peek ¶
Peek gets a transaction (unwrapped) by hash Implemented for compatibility reasons (see transactions.go, common.go).
func (*TxCache) RegisterHandler ¶
RegisterHandler is not implemented
func (*TxCache) RemoveTxByHash ¶
RemoveTxByHash removes transactions with nonces lower or equal to the given transaction's nonce
func (*TxCache) SelectTransactions ¶
func (cache *TxCache) SelectTransactions(session SelectionSession, gasRequested uint64, maxNum int, selectionLoopMaximumDuration time.Duration) ([]*WrappedTransaction, uint64)
SelectTransactions selects the best transactions to be included in the next miniblock. It returns up to "maxNum" transactions, with total gas <= "gasRequested".
func (*TxCache) SizeInBytesContained ¶
SizeInBytesContained returns 0
func (*TxCache) UnRegisterHandler ¶
UnRegisterHandler is not implemented
type WrappedTransaction ¶
type WrappedTransaction struct { Tx data.TransactionHandler TxHash []byte SenderShardID uint32 ReceiverShardID uint32 Size int64 // These fields are only set within "precomputeFields". // We don't need to protect them with a mutex, since "precomputeFields" is called only once for each transaction. // Additional note: "WrappedTransaction" objects are created by the Node, in dataRetriever/txpool/shardedTxPool.go. Fee *big.Int PricePerUnit uint64 TransferredValue *big.Int }
WrappedTransaction contains a transaction, its hash and extra information