Documentation ¶
Index ¶
- Variables
- type ConcurrentMap
- func (m *ConcurrentMap) Clear()
- func (m *ConcurrentMap) Count() int
- func (m *ConcurrentMap) Get(key string) (interface{}, bool)
- func (m *ConcurrentMap) Has(key string) bool
- func (m *ConcurrentMap) IterCb(fn IterCb)
- func (m *ConcurrentMap) Keys() []string
- func (m *ConcurrentMap) Remove(key string)
- func (m *ConcurrentMap) Set(key string, value interface{})
- func (m *ConcurrentMap) SetIfAbsent(key string, value interface{}) bool
- type EvictionConfig
- type ForEachSender
- type ForEachTransaction
- type IterCb
- type TxCache
- func (cache *TxCache) AddTx(txHash []byte, tx data.TransactionHandler) (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) (data.TransactionHandler, bool)
- func (cache *TxCache) GetTransactions(numRequested int, batchSizePerSender int) ([]data.TransactionHandler, [][]byte)
- 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) Peek(key []byte) (value interface{}, ok bool)
- func (cache *TxCache) Put(key []byte, value interface{}) (evicted bool)
- func (cache *TxCache) RegisterHandler(func(key []byte))
- func (cache *TxCache) Remove(key []byte)
- func (cache *TxCache) RemoveOldest()
- func (cache *TxCache) RemoveTxByHash(txHash []byte) error
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 ConcurrentMap ¶ added in v1.0.64
type ConcurrentMap struct {
// contains filtered or unexported fields
}
ConcurrentMap is a thread safe map of type string:Anything. To avoid lock bottlenecks this map is divided to several map chunks.
func NewConcurrentMap ¶ added in v1.0.64
func NewConcurrentMap(nChunks uint32) *ConcurrentMap
NewConcurrentMap creates a new concurrent map.
func (*ConcurrentMap) Count ¶ added in v1.0.64
func (m *ConcurrentMap) Count() int
Count returns the number of elements within the map.
func (*ConcurrentMap) Get ¶ added in v1.0.64
func (m *ConcurrentMap) Get(key string) (interface{}, bool)
Get retrieves an element from map under given key.
func (*ConcurrentMap) Has ¶ added in v1.0.64
func (m *ConcurrentMap) Has(key string) bool
Has looks up an item under specified key.
func (*ConcurrentMap) IterCb ¶ added in v1.0.64
func (m *ConcurrentMap) IterCb(fn IterCb)
IterCb iterates over the map (cheapest way to read all elements in a map)
func (*ConcurrentMap) Keys ¶ added in v1.0.74
func (m *ConcurrentMap) Keys() []string
Keys returns all keys as []string
func (*ConcurrentMap) Remove ¶ added in v1.0.64
func (m *ConcurrentMap) Remove(key string)
Remove removes an element from the map.
func (*ConcurrentMap) Set ¶ added in v1.0.64
func (m *ConcurrentMap) Set(key string, value interface{})
Set sets the given value under the specified key.
func (*ConcurrentMap) SetIfAbsent ¶ added in v1.0.74
func (m *ConcurrentMap) SetIfAbsent(key string, value interface{}) bool
SetIfAbsent sets the given value under the specified key if no value was associated with it.
type EvictionConfig ¶ added in v1.0.64
type EvictionConfig struct { Enabled bool CountThreshold uint32 ThresholdEvictSenders uint32 NumOldestSendersToEvict uint32 ALotOfTransactionsForASender uint32 NumTxsToEvictForASenderWithALot uint32 }
EvictionConfig is a cache eviction model
type ForEachSender ¶
type ForEachSender func(key string, value *txListForSender)
ForEachSender is an iterator callback
type ForEachTransaction ¶
type ForEachTransaction func(txHash []byte, value data.TransactionHandler)
ForEachTransaction is an iterator callback
type IterCb ¶ added in v1.0.64
type IterCb func(key string, v interface{})
IterCb 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 ¶
NewTxCache creates a new transaction cache "nChunksHint" is used to configure the internal concurrent maps on which the implementation relies
func NewTxCacheWithEviction ¶ added in v1.0.64
func NewTxCacheWithEviction(nChunksHint uint32, evictionConfig EvictionConfig) *TxCache
NewTxCacheWithEviction creates a new transaction cache with eviction
func (*TxCache) AddTx ¶
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) (data.TransactionHandler, bool)
GetByTxHash gets the transaction by hash
func (*TxCache) GetTransactions ¶ added in v1.0.64
func (cache *TxCache) GetTransactions(numRequested int, batchSizePerSender int) ([]data.TransactionHandler, [][]byte)
GetTransactions gets 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
func (*TxCache) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*TxCache) RegisterHandler ¶
RegisterHandler is not implemented
func (*TxCache) RemoveTxByHash ¶
RemoveTxByHash removes tx by hash