CatapultServer  v0.5.0.1 (Elephant)
AccountStateCacheTypes.h
Go to the documentation of this file.
1 
21 #pragma once
27 #include "catapult/utils/Casting.h"
28 #include "catapult/utils/Hashers.h"
29 
30 namespace catapult {
31  namespace cache {
32  struct AccountStateBaseSetDeltaPointers;
33  struct AccountStateBaseSets;
34  class AccountStateCache;
35  class AccountStateCacheDelta;
36  class AccountStateCacheView;
37  class AccountStatePatriciaTree;
38  struct AccountStatePrimarySerializer;
39  class BasicAccountStateCacheDelta;
40  class BasicAccountStateCacheView;
41  struct KeyAddressPairSerializer;
42  class ReadOnlyAccountStateCache;
43  }
44 }
45 
46 namespace catapult { namespace cache {
47 
50  public:
51  static constexpr auto Name = "AccountStateCache:Address";
52 
53  public:
54  // key value types
55  using KeyType = Address;
57 
58  // cache types
62 
65 
66  public:
68  static auto GetKeyFromValue(const ValueType& accountState) {
69  return accountState.Address;
70  }
71  };
72 
75  public:
77 
79  struct Options {
82 
85 
89 
92 
95  };
96 
97  // region secondary descriptors
98 
99  public:
102  public:
103  using KeyType = Key;
104  using ValueType = std::pair<Key, Address>;
106 
107  public:
108  static auto GetKeyFromValue(const ValueType& pair) {
109  return pair.first;
110  }
111  };
112 
113  // endregion
114 
115  // region other adapters
116 
117  public:
120  template<typename TSets>
122  public:
123  static constexpr auto Name = TSets::Name;
124 
125  private:
126  using SetOneType = typename TSets::SetOneType;
127  using SetTwoType = typename TSets::SetTwoType;
128 
129  public:
130  using KeyType = typename SetOneType::KeyType;
131  using ValueType = typename SetTwoType::ElementType;
132 
133  public:
135  : m_set1(set1)
136  , m_set2(set2)
137  {}
138 
139  public:
140  using FindIterator = typename TSets::FindIterator;
141  using FindConstIterator = typename TSets::FindConstIterator;
142 
143  public:
144  FindConstIterator find(const KeyType& key) const {
145  auto setOneIter = m_set1.find(key);
146  const auto* pPair = setOneIter.get();
147  return pPair ? utils::as_const(m_set2).find(pPair->second) : FindConstIterator();
148  }
149 
150  FindIterator find(const KeyType& key) {
151  auto setOneIter = m_set1.find(key);
152  const auto* pPair = setOneIter.get();
153  return pPair ? m_set2.find(pPair->second) : FindIterator();
154  }
155 
156  private:
159  };
160 
161  // endregion
162 
163  public:
166 
167  public:
168  // workaround for VS truncation
170  static constexpr auto Name = "AccountStateCache:Key";
171 
174 
177  };
178 
180  static constexpr auto Name = "AccountStateCache:Key";
181 
184 
185  using FindIterator = SetTwoType::FindIterator;
186  using FindConstIterator = SetTwoType::FindConstIterator;
187  };
188 
189  public:
192  };
193 }}
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::ComposedLookupAdapter
ComposedLookupAdapter(const SetOneType &set1, SetTwoType &set2)
Definition: AccountStateCacheTypes.h:134
catapult::cache::AccountStateCacheTypes::ComposableBaseSetDeltas::Name
static constexpr auto Name
Definition: AccountStateCacheTypes.h:180
catapult::cache::AccountStateCacheTypes::KeyLookupMapTypesDescriptor::ValueType
std::pair< Key, Address > ValueType
Definition: AccountStateCacheTypes.h:104
catapult::cache::AccountStateCacheTypes::Options::ImportanceGrouping
uint64_t ImportanceGrouping
Importance grouping.
Definition: AccountStateCacheTypes.h:84
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::find
FindIterator find(const KeyType &key)
Definition: AccountStateCacheTypes.h:150
catapult::cache::AccountStateCacheDescriptor::Name
static constexpr auto Name
Definition: AccountStateCacheTypes.h:51
catapult::state::AccountState
Account state data.
Definition: AccountState.h:44
catapult::cache::AccountStateCacheTypes::ComposableBaseSetDeltas::FindConstIterator
SetTwoType::FindConstIterator FindConstIterator
Definition: AccountStateCacheTypes.h:186
catapult::cache::detail::UnorderedMapAdapter::BaseSetDeltaType
typename BaseSetType::DeltaType BaseSetDeltaType
Base set delta type.
Definition: CacheDescriptorAdapters.h:84
catapult::cache::AccountStateCacheTypes
AccountState cache types.
Definition: AccountStateCacheTypes.h:74
catapult::utils::as_const
constexpr const T & as_const(T &ref)
Coerces a reference (ref) to a const reference.
Definition: Casting.h:31
catapult::cache::AccountStatePrimarySerializer
Primary serializer for account state cache.
Definition: AccountStateCacheSerializers.h:29
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::SetOneType
typename TSets::SetOneType SetOneType
Definition: AccountStateCacheTypes.h:126
catapult::cache::AccountStateCacheTypes::Options::HarvestingMosaicId
MosaicId HarvestingMosaicId
Mosaic id used to provide harvesting ability.
Definition: AccountStateCacheTypes.h:94
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::ValueType
typename SetTwoType::ElementType ValueType
Definition: AccountStateCacheTypes.h:131
catapult::cache::AccountStateBaseSetDeltaPointers
Definition: AccountStateBaseSets.h:41
catapult::utils::BaseValue< uint64_t, Amount_tag >
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::m_set1
const SetOneType & m_set1
Definition: AccountStateCacheTypes.h:157
catapult::cache::AccountStateCacheTypes::ComposableBaseSetDeltas::SetOneType
const KeyLookupMapTypes::BaseSetDeltaType SetOneType
Definition: AccountStateCacheTypes.h:182
catapult::cache::AccountStateCacheTypes::ComposableBaseSets
Definition: AccountStateCacheTypes.h:169
catapult::cache::AccountStateCacheTypes::Options
Custom sub view options.
Definition: AccountStateCacheTypes.h:79
catapult::state::AccountState::Address
catapult::Address Address
Address of an account.
Definition: AccountState.h:58
NetworkInfo.h
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::FindConstIterator
typename TSets::FindConstIterator FindConstIterator
Definition: AccountStateCacheTypes.h:141
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::m_set2
SetTwoType & m_set2
Definition: AccountStateCacheTypes.h:158
catapult::cache::AccountStateCacheDescriptor
Describes an account state cache.
Definition: AccountStateCacheTypes.h:49
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::KeyType
typename SetOneType::KeyType KeyType
Definition: AccountStateCacheTypes.h:130
catapult::cache::AccountStateCacheTypes::ComposableBaseSetDeltas
Definition: AccountStateCacheTypes.h:179
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::SetTwoType
typename TSets::SetTwoType SetTwoType
Definition: AccountStateCacheTypes.h:127
catapult::deltaset::detail::BaseSetSingleIteratorWrapper
Definition: BaseSetFindIterator.h:30
catapult::cache::AccountStateCacheDelta
Delta on top of the account state cache.
Definition: AccountStateCacheDelta.h:179
catapult::cache::AccountStateCacheTypes::ComposableBaseSets::Name
static constexpr auto Name
Definition: AccountStateCacheTypes.h:170
catapult::cache::detail::UnorderedMapAdapter::BaseSetType
deltaset::BaseSet< TElementTraits, StorageTraits > BaseSetType
Base set type.
Definition: CacheDescriptorAdapters.h:81
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::FindIterator
typename TSets::FindIterator FindIterator
Definition: AccountStateCacheTypes.h:140
CacheDatabaseMixin.h
catapult::cache::AccountStateCacheTypes::ComposableBaseSetDeltas::FindIterator
SetTwoType::FindIterator FindIterator
Definition: AccountStateCacheTypes.h:185
Name
static constexpr auto Name
Definition: PtSynchronizer.cpp:31
catapult::deltaset::BaseSet
Definition: BaseSet.h:52
CacheDescriptorAdapters.h
catapult::cache::CacheId::AccountState
catapult::model::NetworkIdentifier
NetworkIdentifier
Possible network identifiers.
Definition: NetworkInfo.h:45
catapult::cache::AccountStateCache
Synchronized cache composed of stateful account information.
Definition: AccountStateCache.h:72
catapult::cache::KeyAddressPairSerializer
Serializer for key address lookup sub cache.
Definition: AccountStateCacheSerializers.h:38
AccountState.h
catapult::cache::AccountStateCacheTypes::Options::CurrencyMosaicId
MosaicId CurrencyMosaicId
Mosaic id used as primary chain currency.
Definition: AccountStateCacheTypes.h:91
catapult::cache::AccountStateCacheTypes::ComposableBaseSetDeltas::SetTwoType
PrimaryTypes::BaseSetDeltaType SetTwoType
Definition: AccountStateCacheTypes.h:183
catapult::cache::AccountStatePatriciaTree
Definition: AccountStateBaseSets.h:35
catapult::deltaset::BaseSet::FindConstIterator
BaseSetFindIterator< FindTraits, TSetTraits > FindConstIterator
Definition: BaseSet.h:60
catapult::cache::AccountStateCacheTypes::KeyLookupMapTypesDescriptor
Describes a key-based interface on top of an account state cache.
Definition: AccountStateCacheTypes.h:101
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter
Definition: AccountStateCacheTypes.h:121
catapult::cache::AccountStateBaseSets
Definition: AccountStateBaseSets.h:47
catapult::cache::AccountStateCacheTypes::Options::MinHarvesterBalance
Amount MinHarvesterBalance
Definition: AccountStateCacheTypes.h:88
Casting.h
catapult::cache::AccountStateCacheTypes::Options::NetworkIdentifier
model::NetworkIdentifier NetworkIdentifier
Network identifier.
Definition: AccountStateCacheTypes.h:81
catapult
Definition: AddressExtractionExtension.cpp:28
Hashers.h
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::find
FindConstIterator find(const KeyType &key) const
Definition: AccountStateCacheTypes.h:144
catapult::cache::AccountStateCacheTypes::KeyLookupMapTypesDescriptor::GetKeyFromValue
static auto GetKeyFromValue(const ValueType &pair)
Definition: AccountStateCacheTypes.h:108
catapult::utils::ByteArray< Address_Decoded_Size, Address_tag >
catapult::cache::ReadOnlyAccountStateCache
A read-only overlay on top of an account cache.
Definition: ReadOnlyAccountStateCache.h:36
BaseSetDelta.h
catapult::cache::AccountStateCacheTypes::ComposedLookupAdapter::Name
static constexpr auto Name
Definition: AccountStateCacheTypes.h:123
catapult::cache::AccountStateCacheView
View on top of the account state cache.
Definition: AccountStateCacheView.h:110
catapult::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
catapult::cache::AccountStateCacheDescriptor::GetKeyFromValue
static auto GetKeyFromValue(const ValueType &accountState)
Gets the key corresponding to accountState.
Definition: AccountStateCacheTypes.h:68
catapult::cache::detail::UnorderedMapAdapter
Defines cache types for an unordered map based cache.
Definition: CacheDescriptorAdapters.h:35