CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
29 #include <unordered_map>
31 namespace catapult {
namespace cache {
struct TransactionData; } }
33 namespace catapult {
namespace cache {
43 using IdLookup = std::unordered_map<Hash256, size_t, utils::ArrayHasher<Hash256>>;
50 uint64_t maxResponseSize,
TransactionInfo()=default
Creates a transaction info.
TransactionData(size_t id)
Definition: MemoryUtCache.cpp:36
ShortHash ToShortHash(const Hash256 &hash)
Gets the short hash corresponding to hash.
Definition: ShortHash.h:42
size_t & m_idSequence
Definition: MemoryUtCache.cpp:196
AccountCounters & m_counters
Definition: MemoryUtCache.cpp:199
const IdLookup & m_idLookup
Definition: MemoryUtCache.h:76
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
utils::SpinReaderWriterLock::ReaderLockGuard m_readLock
Definition: MemoryUtCache.h:77
A delegating proxy around a memory-based cache.
Definition: MemoryCacheProxy.h:29
size_t size() const
Returns the number of unconfirmed transactions in the cache.
Definition: MemoryUtCache.cpp:63
utils::ByteArray< Hash256_Size, Hash256_tag > Hash256
Definition: src/catapult/types.h:47
def debug(*args)
Definition: Parser.py:46
size_t m_idSequence
Definition: MemoryUtCache.h:101
A delegating proxy around a MemoryUtCache.
Definition: MemoryUtCache.h:107
std::function< bool(TArgs...)> predicate
A predicate function.
Definition: functions.h:31
uint64_t MaxCacheSize
Maximum size of the cache.
Definition: MemoryCacheOptions.h:44
utils::SpinReaderWriterLock m_lock
Definition: MemoryUtCache.h:103
TransactionDataContainer & m_transactionDataContainer
Definition: MemoryUtCache.cpp:197
Represents a range of entities.
Definition: EntityRange.h:31
~MemoryUtCache() override
Destroys an unconfirmed transactions cache.
void LogSizes(const char *name, size_t actual, uint64_t max)
Logs cache sizes for a cache with name at specified levels of fullness given its actual and max sizes...
Definition: CacheSizeLogger.h:27
uint64_t m_maxCacheSize
Definition: MemoryUtCache.cpp:195
auto begin() const
Returns a const iterator that represents the first entity.
Definition: EntityRange.h:420
A transaction and its associated metadata.
Definition: EntityInfo.h:104
Definition: MemoryUtCache.cpp:209
MemoryUtCache(const MemoryCacheOptions &options)
Creates an unconfirmed transactions cache around options.
Definition: MemoryUtCache.cpp:215
IdLookup & m_idLookup
Definition: MemoryUtCache.cpp:198
std::vector< std::shared_ptr< const model::Transaction > > UnknownTransactions
Definition: MemoryUtCache.h:42
ReaderLockGuard acquireReader()
Blocks until a reader lock can be acquired.
Definition: SpinReaderWriterLock.h:153
std::unordered_map< Hash256, size_t, utils::ArrayHasher< Hash256 > > IdLookup
Definition: MemoryUtCache.h:43
model::ShortHashRange shortHashes() const
Definition: MemoryUtCache.cpp:78
bool operator<(const TransactionData &rhs) const
Definition: MemoryUtCache.cpp:42
Definition: MemoryUtCache.cpp:29
utils::SpinReaderWriterLock::ReaderLockGuard m_readLock
Definition: MemoryUtCache.cpp:200
static EntityRange PrepareFixed(size_t numElements, uint8_t **ppRangeData=nullptr)
Definition: EntityRange.h:265
An interface for caching unconfirmed transactions.
Definition: UtCache.h:56
uint64_t m_maxResponseSize
Definition: MemoryUtCache.h:74
uint64_t MaxResponseSize
Maximum response size.
Definition: MemoryCacheOptions.h:41
void forEach(const TransactionInfoConsumer &consumer) const
Calls consumer with all transaction infos until all are consumed or false is returned by consumer.
Definition: MemoryUtCache.cpp:71
predicate< const model::TransactionInfo & > TransactionInfoConsumer
Definition: MemoryUtCache.h:44
MemoryUtCacheView(uint64_t maxResponseSize, const TransactionDataContainer &transactionDataContainer, const IdLookup &idLookup, utils::SpinReaderWriterLock::ReaderLockGuard &&readLock)
Definition: MemoryUtCache.cpp:52
bool contains(const Hash256 &hash) const
Returns true if the cache contains an unconfirmed transaction with associated hash,...
Definition: MemoryUtCache.cpp:67
TransactionData(const model::TransactionInfo &transactionInfo, size_t id)
Definition: MemoryUtCache.cpp:31
std::unordered_set< ShortHash, ShortHashHasher > ShortHashesSet
Definition: ShortHash.h:39
uint64_t size
Definition: MemoryCounters.cpp:65
std::unique_ptr< Impl > m_pImpl
Definition: MemoryUtCache.h:102
utils::SpinReaderWriterLock::WriterLockGuard m_writeLock
Definition: MemoryUtCache.cpp:201
std::unordered_map< Hash256, size_t, utils::ArrayHasher< Hash256 > > IdLookup
Definition: MemoryUtCache.cpp:211
A read only view on top of unconfirmed transactions cache.
Definition: MemoryUtCache.h:40
A reader lock guard.
Definition: SpinReaderWriterLock.h:99
Cache for all unconfirmed transactions.
Definition: MemoryUtCache.h:81
AccountCounters Counters
Definition: MemoryUtCache.cpp:212
CompareChainsOptions m_options
Definition: CompareChains.cpp:165
cache::TransactionDataContainer TransactionDataContainer
Definition: MemoryUtCache.cpp:210
UtCacheModifierProxy modifier() override
Gets a write only view of the cache.
Definition: MemoryUtCache.cpp:228
std::set< TransactionData > TransactionDataContainer
Definition: MemoryUtCache.h:37
Definition: AddressExtractionExtension.cpp:28
size_t Id
Definition: MemoryUtCache.cpp:47
UnknownTransactions unknownTransactions(BlockFeeMultiplier minFeeMultiplier, const utils::ShortHashesSet &knownShortHashes) const
Definition: MemoryUtCache.cpp:87
MemoryUtCacheView view() const
Gets a read only view based on this cache.
Definition: MemoryUtCache.cpp:223
Amount CalculateTransactionFee(BlockFeeMultiplier feeMultiplier, const Transaction &transaction)
Calculates the fee for transaction contained in block with feeMultiplier.
Definition: FeeUtils.cpp:26
A class that can neither be copied nor moved.
Definition: NonCopyable.h:26
Options for customizing the behavior of a memory based cache.
Definition: MemoryCacheOptions.h:27
Counters for tracking how often an account is used.
Definition: AccountCounters.h:29
An interface for modifying an unconfirmed transactions cache.
Definition: UtCache.h:28
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
Definition: SpinReaderWriterLock.h:36
MemoryCacheOptions m_options
Definition: MemoryUtCache.h:97
const TransactionDataContainer & m_transactionDataContainer
Definition: MemoryUtCache.h:75
TransactionInfo copy() const
Creates a (shallow) copy of this info.
Definition: EntityInfo.h:122