CatapultServer  v0.5.0.1 (Elephant)
PtCache.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "BasicTransactionsCache.h"
23 #include "catapult/functions.h"
24 #include <vector>
25 
26 namespace catapult { namespace cache {
27 
30  class PtCacheModifier : public BasicTransactionsCacheModifier<model::DetachedTransactionInfo> {
31  public:
33 
34  public:
36  virtual model::DetachedTransactionInfo add(const Hash256& parentHash, const Key& signer, const Signature& signature) = 0;
37 
39  virtual std::vector<model::DetachedTransactionInfo> prune(Timestamp timestamp) = 0;
40 
42  virtual std::vector<model::DetachedTransactionInfo> prune(const predicate<const Hash256&>& hashPredicate) = 0;
43  };
44 
47  class PtCacheModifierProxy final : public BasicTransactionsCacheModifierProxy<model::DetachedTransactionInfo, PtCacheModifier> {
48  public:
51  using BaseType::add;
52 
53  public:
55  model::DetachedTransactionInfo add(const Hash256& parentHash, const Key& signer, const Signature& signature) {
56  return modifier().add(parentHash, signer, signature);
57  }
58 
60  std::vector<model::DetachedTransactionInfo> prune(Timestamp timestamp) {
61  return modifier().prune(timestamp);
62  }
63 
65  std::vector<model::DetachedTransactionInfo> prune(const predicate<const Hash256&>& hashPredicate) {
66  return modifier().prune(hashPredicate);
67  }
68  };
69 
71  class PtCache : public BasicTransactionsCache<PtCacheModifierProxy> {};
72 }}
catapult::cache::BasicTransactionsCacheModifierProxy< model::DetachedTransactionInfo, PtCacheModifier >::BasicTransactionsCacheModifierProxy
BasicTransactionsCacheModifierProxy(std::unique_ptr< PtCacheModifier > &&pModifier)
Creates a transactions cache modifier around pModifier.
Definition: BasicTransactionsCache.h:53
catapult::cache::PtCacheModifierProxy::prune
std::vector< model::DetachedTransactionInfo > prune(Timestamp timestamp)
Removes all partial transactions that have deadlines at or before the given timestamp.
Definition: PtCache.h:60
catapult::predicate
std::function< bool(TArgs...)> predicate
A predicate function.
Definition: functions.h:31
BasicTransactionsCache.h
catapult::cache::BasicTransactionsCacheModifierProxy< model::DetachedTransactionInfo, PtCacheModifier >::add
bool add(const model::DetachedTransactionInfo &transactionInfo)
Definition: BasicTransactionsCache.h:65
functions.h
catapult::utils::BaseValue< uint64_t, Timestamp_tag >
catapult::cache::BasicTransactionsCacheModifierProxy< model::DetachedTransactionInfo, PtCacheModifier >::modifier
PtCacheModifier & modifier()
Gets the modifier.
Definition: BasicTransactionsCache.h:76
catapult::cache::BasicTransactionsCacheModifierProxy
Definition: BasicTransactionsCache.h:50
catapult::cache::BasicTransactionsCacheModifier
An interface for modifying a transactions cache.
Definition: BasicTransactionsCache.h:30
catapult::cache::PtCacheModifierProxy::prune
std::vector< model::DetachedTransactionInfo > prune(const predicate< const Hash256 & > &hashPredicate)
Removes all partial transactions for which hashPredicate returns true.
Definition: PtCache.h:65
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::PtCacheModifierProxy
Definition: PtCache.h:47
catapult::cache::BasicTransactionsCache
An interface for caching transactions.
Definition: BasicTransactionsCache.h:91
catapult::cache::PtCache
An interface for caching partial transactions.
Definition: PtCache.h:71
catapult::cache::PtCacheModifier::add
virtual model::DetachedTransactionInfo add(const Hash256 &parentHash, const Key &signer, const Signature &signature)=0
Adds a cosignature (composed of signer and signature) for a partial transaction with hash parentHash ...
catapult::utils::ByteArray< Hash256_Size, Hash256_tag >
catapult::cache::PtCacheModifierProxy::add
model::DetachedTransactionInfo add(const Hash256 &parentHash, const Key &signer, const Signature &signature)
Adds a cosignature (composed of signer and signature) for a partial transaction with hash parentHash ...
Definition: PtCache.h:55
catapult::cache::PtCacheModifier::prune
virtual std::vector< model::DetachedTransactionInfo > prune(Timestamp timestamp)=0
Removes all partial transactions that have deadlines at or before the given timestamp.
catapult::cache::PtCacheModifier
Definition: PtCache.h:30
catapult::model::DetachedTransactionInfo
Definition: EntityInfo.h:77