Documentation ¶
Index ¶
- Variables
- type CacheConfig
- type DisabledCache
- func (cache *DisabledCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)
- func (cache *DisabledCache) Clear()
- func (cache *DisabledCache) CountTx() int64
- func (cache *DisabledCache) ForEachTransaction(function ForEachTransaction)
- func (cache *DisabledCache) Get(key []byte) (value interface{}, ok bool)
- func (cache *DisabledCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
- func (cache *DisabledCache) Has(key []byte) bool
- func (cache *DisabledCache) HasOrAdd(key []byte, value interface{}) (ok, evicted bool)
- func (cache *DisabledCache) IsInterfaceNil() bool
- func (cache *DisabledCache) Len() int
- func (cache *DisabledCache) MaxSize() int
- func (cache *DisabledCache) Peek(key []byte) (value interface{}, ok bool)
- func (cache *DisabledCache) Put(key []byte, value interface{}) (evicted bool)
- func (cache *DisabledCache) RegisterHandler(func(key []byte, value interface{}))
- func (cache *DisabledCache) Remove(key []byte)
- func (cache *DisabledCache) RemoveOldest()
- func (cache *DisabledCache) RemoveTxByHash(txHash []byte) error
- func (cache *DisabledCache) SelectTransactions(numRequested int, batchSizePerSender int) []*WrappedTransaction
- type ForEachTransaction
- type TxCache
- func (cache *TxCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)
- func (cache *TxCache) Clear()
- func (cache *TxCache) CountSenders() int64
- func (cache *TxCache) CountTx() int64
- 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) Has(key []byte) bool
- func (cache *TxCache) HasOrAdd(key []byte, value interface{}) (ok, evicted bool)
- func (cache *TxCache) IsInterfaceNil() bool
- func (cache *TxCache) Keys() [][]byte
- func (cache *TxCache) Len() int
- func (cache *TxCache) MaxSize() int
- func (cache *TxCache) NotifyAccountNonce(accountKey []byte, nonce uint64)
- func (cache *TxCache) NumBytes() int64
- func (cache *TxCache) Peek(key []byte) (value interface{}, ok bool)
- func (cache *TxCache) Put(key []byte, value interface{}) (evicted bool)
- func (cache *TxCache) RegisterHandler(func(key []byte, value interface{}))
- func (cache *TxCache) Remove(key []byte)
- func (cache *TxCache) RemoveOldest()
- func (cache *TxCache) RemoveTxByHash(txHash []byte) error
- func (cache *TxCache) SelectTransactions(numRequested int, batchSizePerSender int) []*WrappedTransaction
- type WrappedTransaction
Constants ¶
This section is empty.
Variables ¶
var ErrMapsSyncInconsistency = fmt.Errorf("maps sync inconsistency between 'txByHash' and 'txListBySender'")
ErrMapsSyncInconsistency signals that there's an inconsistency between the internal maps on which the cache relies
var ErrTxNotFound = fmt.Errorf("tx not found in cache")
ErrTxNotFound signals that the transactions was not found in the cache
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type CacheConfig struct { Name string NumChunksHint uint32 EvictionEnabled bool NumBytesThreshold uint32 CountThreshold uint32 NumSendersToEvictInOneStep uint32 LargeNumOfTxsForASender uint32 NumTxsToEvictFromASender uint32 MinGasPriceNanoErd uint32 }
CacheConfig holds cache configuration
type DisabledCache ¶ added in v1.0.116
type DisabledCache struct { }
DisabledCache represents a disabled cache
func NewDisabledCache ¶ added in v1.0.116
func NewDisabledCache() *DisabledCache
NewDisabledCache creates a new disabled cache
func (*DisabledCache) AddTx ¶ added in v1.0.116
func (cache *DisabledCache) AddTx(tx *WrappedTransaction) (ok bool, added bool)
AddTx does nothing
func (*DisabledCache) Clear ¶ added in v1.0.116
func (cache *DisabledCache) Clear()
Clear does nothing
func (*DisabledCache) CountTx ¶ added in v1.0.116
func (cache *DisabledCache) CountTx() int64
CountTx returns zero
func (*DisabledCache) ForEachTransaction ¶ added in v1.0.116
func (cache *DisabledCache) ForEachTransaction(function ForEachTransaction)
ForEachTransaction does nothing
func (*DisabledCache) Get ¶ added in v1.0.116
func (cache *DisabledCache) Get(key []byte) (value interface{}, ok bool)
Get returns no transaction
func (*DisabledCache) GetByTxHash ¶ added in v1.0.116
func (cache *DisabledCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
GetByTxHash returns no transaction
func (*DisabledCache) Has ¶ added in v1.0.116
func (cache *DisabledCache) Has(key []byte) bool
Has returns false
func (*DisabledCache) HasOrAdd ¶ added in v1.0.116
func (cache *DisabledCache) HasOrAdd(key []byte, value interface{}) (ok, evicted bool)
HasOrAdd returns false, does nothing
func (*DisabledCache) IsInterfaceNil ¶ added in v1.0.116
func (cache *DisabledCache) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*DisabledCache) Len ¶ added in v1.0.116
func (cache *DisabledCache) Len() int
Len returns zero
func (*DisabledCache) MaxSize ¶ added in v1.0.116
func (cache *DisabledCache) MaxSize() int
MaxSize returns zero
func (*DisabledCache) Peek ¶ added in v1.0.116
func (cache *DisabledCache) Peek(key []byte) (value interface{}, ok bool)
Peek returns no transaction
func (*DisabledCache) Put ¶ added in v1.0.116
func (cache *DisabledCache) Put(key []byte, value interface{}) (evicted bool)
Put does nothing
func (*DisabledCache) RegisterHandler ¶ added in v1.0.116
func (cache *DisabledCache) RegisterHandler(func(key []byte, value interface{}))
RegisterHandler does nothing
func (*DisabledCache) Remove ¶ added in v1.0.116
func (cache *DisabledCache) Remove(key []byte)
Remove does nothing
func (*DisabledCache) RemoveOldest ¶ added in v1.0.116
func (cache *DisabledCache) RemoveOldest()
RemoveOldest does nothing
func (*DisabledCache) RemoveTxByHash ¶ added in v1.0.116
func (cache *DisabledCache) RemoveTxByHash(txHash []byte) error
RemoveTxByHash does nothing
func (*DisabledCache) SelectTransactions ¶ added in v1.0.116
func (cache *DisabledCache) SelectTransactions(numRequested int, batchSizePerSender int) []*WrappedTransaction
SelectTransactions returns an empty slice
type ForEachTransaction ¶
type ForEachTransaction func(txHash []byte, value *WrappedTransaction)
ForEachTransaction is an iterator callback
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 CacheConfig) *TxCache
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) ForEachTransaction ¶
func (cache *TxCache) ForEachTransaction(function ForEachTransaction)
ForEachTransaction iterates over the transactions in the cache
func (*TxCache) GetByTxHash ¶
func (cache *TxCache) GetByTxHash(txHash []byte) (*WrappedTransaction, bool)
GetByTxHash gets the transaction by hash
func (*TxCache) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*TxCache) NotifyAccountNonce ¶
NotifyAccountNonce should be called by external components (such as interceptors and transactions processor) in order to inform the cache about initial nonce gap phenomena
func (*TxCache) RegisterHandler ¶
RegisterHandler is not implemented
func (*TxCache) RemoveTxByHash ¶
RemoveTxByHash removes tx by hash
func (*TxCache) SelectTransactions ¶
func (cache *TxCache) SelectTransactions(numRequested int, batchSizePerSender int) []*WrappedTransaction
SelectTransactions selects a reasonably fair list of transactions to be included in the next miniblock It returns at most "numRequested" transactions Each sender gets the chance to give at least "batchSizePerSender" transactions, unless "numRequested" limit is reached before iterating over all senders
type WrappedTransaction ¶
type WrappedTransaction struct { Tx data.TransactionHandler TxHash []byte SenderShardID uint32 ReceiverShardID uint32 }
WrappedTransaction contains a transaction, its hash and extra information