CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
28 namespace catapult {
namespace cache {
31 template<
typename TCache,
typename TStorageTraits>
36 std::ostringstream out;
42 const std::string&
name()
const override {
46 size_t id()
const override {
51 std::unique_ptr<const SubCacheView>
createView()
const override {
52 return std::make_unique<
const SubCacheViewAdapter<decltype(
m_pCache->createView())>>(
58 return std::make_unique<SubCacheViewAdapter<decltype(
m_pCache->createDelta())>>(
64 return std::make_unique<DetachedSubCacheViewAdapter<decltype(
m_pCache->createDetachedDelta())>>(
74 const void*
get()
const override {
81 ? std::make_unique<CacheStorageAdapter<TCache, TStorageTraits>>(*m_pCache)
86 return std::make_unique<CacheChangesStorageAdapter<TCache, TStorageTraits>>(*m_pCache);
98 std::memcpy(viewIdentifier.CacheName.data(),
name().data(), viewIdentifier.CacheName.size());
100 viewIdentifier.ViewType = viewType;
101 return viewIdentifier;
106 return !!
cache.createView()->tryMakeIterableView();
112 template<
typename TView>
123 using UnderlyingViewType = std::remove_reference_t<decltype(*
m_view)>;
129 using UnderlyingViewType = std::remove_reference_t<decltype(*
m_view)>;
138 const void*
get()
const override {
163 return &
m_view->asReadOnly();
171 template<
typename T,
typename =
void>
181 template<
typename T,
typename =
void>
196 return view->supportsMerkleRoot();
204 auto result = view->tryGetMerkleRoot();
205 merkleRoot = result.first;
206 return result.second;
214 if (!view->supportsMerkleRoot())
217 view->setMerkleRoot(merkleRoot);
225 view->updateMerkleRoot(height);
237 template<
typename TLockableCacheDelta>
Definition: SubCachePluginAdapter.h:172
static bool TrySetMerkleRoot(TView &view, const Hash256 &merkleRoot, SupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:213
TView m_view
Definition: SubCachePluginAdapter.h:229
size_t id() const override
Gets the cache id.
Definition: SubCachePluginAdapter.h:46
SubCacheViewType
Sub cache view types.
Definition: SubCachePlugin.h:39
static void UpdateMerkleRoot(TView &, Height, UnsupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:221
static bool TryGetMerkleRoot(const TView &, Hash256 &, UnsupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:199
std::unique_ptr< CacheStorage > createStorage() override
Returns a cache storage based on this cache.
Definition: SubCachePluginAdapter.h:79
bool supportsMerkleRoot() const override
Returns true if cache supports merkle root.
Definition: SubCachePluginAdapter.h:146
Sub cache view identifier.
Definition: SubCachePlugin.h:51
std::unique_ptr< CacheChangesStorage > createChangesStorage() const override
Returns a cache changes storage based on this cache.
Definition: SubCachePluginAdapter.h:85
TLockableCacheDelta m_lockableCacheDelta
Definition: SubCachePluginAdapter.h:252
auto merkleRootMutator()
Definition: SubCachePluginAdapter.h:127
std::integral_constant< MerkleRootType, MerkleRootType::Unsupported > UnsupportedMerkleRootFlag
Definition: SubCachePluginAdapter.h:168
static bool SupportsMerkleRoot(const TView &, UnsupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:191
Definition: SubCachePluginAdapter.h:113
std::unique_ptr< SubCacheView > tryLock()
Definition: SubCachePluginAdapter.h:246
static bool IsCacheStorageSupported(const TCache &cache)
Definition: SubCachePluginAdapter.h:105
const SubCacheViewIdentifier & id() const override
Gets view identifier.
Definition: SubCachePluginAdapter.h:134
void * get() override
Returns a pointer to the underlying view.
Definition: SubCachePluginAdapter.h:142
SubCacheViewIdentifier m_id
Definition: SubCachePluginAdapter.h:253
Detached sub cache view.
Definition: SubCachePlugin.h:99
NamespaceId Id
Definition: RootNamespaceHistorySerializer.cpp:100
TCache & cache()
Gets a typed reference to the underlying cache.
Definition: SubCachePluginAdapter.h:91
const void * get() const override
Returns a const pointer to the underlying cache.
Definition: SubCachePluginAdapter.h:74
SubCacheViewAdapter(TView &&view, const SubCacheViewIdentifier &id)
Definition: SubCachePluginAdapter.h:115
const void * get() const override
Returns a const pointer to the underlying view.
Definition: SubCachePluginAdapter.h:138
auto makeSubCacheViewIdentifier(SubCacheViewType viewType) const
Definition: SubCachePluginAdapter.h:96
static bool SupportsMerkleRoot(const TView &view, SupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:195
bool trySetMerkleRoot(const Hash256 &merkleRoot) override
Sets the cache merkle root (merkleRoot) if supported.
Definition: SubCachePluginAdapter.h:154
size_t CacheId
Cache id.
Definition: SubCachePlugin.h:57
Definition: SubCachePluginAdapter.h:238
const std::string & name() const override
Gets the cache name.
Definition: SubCachePluginAdapter.h:42
std::string m_name
Definition: SubCachePluginAdapter.h:260
auto merkleRootAccessor() const
Definition: SubCachePluginAdapter.h:121
const void * asReadOnly() const override
Returns a read-only view of this view.
Definition: SubCachePluginAdapter.h:162
SubCacheViewIdentifier m_id
Definition: SubCachePluginAdapter.h:230
bool tryGetMerkleRoot(Hash256 &merkleRoot) const override
Gets the cache merkle root (merkleRoot) if supported.
Definition: SubCachePluginAdapter.h:150
void commit() override
Commits all pending changes to the underlying storage.
Definition: SubCachePluginAdapter.h:69
Sub cache view.
Definition: SubCachePlugin.h:68
typename is_type_expression< T, Enable >::type is_type_expression_t
true if the expression is valid and evaluates to a type, false otherwise.
Definition: Traits.h:98
Sub cache plugin that can be added to the main catapult cache.
Definition: SubCachePlugin.h:114
static constexpr auto Name
Definition: PtSynchronizer.cpp:31
SubCachePluginAdapter(std::unique_ptr< TCache > &&pCache)
Creates an adapter around pCache.
Definition: SubCachePluginAdapter.h:35
static bool TryGetMerkleRoot(const TView &view, Hash256 &merkleRoot, SupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:203
std::unique_ptr< DetachedSubCacheView > createDetachedDelta() const override
Definition: SubCachePluginAdapter.h:63
static void UpdateMerkleRoot(TView &view, Height height, SupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:224
std::unique_ptr< const SubCacheView > createView() const override
Returns a locked cache view based on this cache.
Definition: SubCachePluginAdapter.h:51
static bool TrySetMerkleRoot(TView &, const Hash256 &, UnsupportedMerkleRootFlag)
Definition: SubCachePluginAdapter.h:209
Definition: SubCachePluginAdapter.h:182
std::unique_ptr< SubCacheView > createDelta() override
Definition: SubCachePluginAdapter.h:57
Definition: AddressExtractionExtension.cpp:28
DetachedSubCacheViewAdapter(TLockableCacheDelta &&lockableCacheDelta, const SubCacheViewIdentifier &id)
Definition: SubCachePluginAdapter.h:240
void updateMerkleRoot(Height height) override
Recalculates the merkle root given the specified chain height if supported.
Definition: SubCachePluginAdapter.h:158
std::unique_ptr< TCache > m_pCache
Definition: SubCachePluginAdapter.h:259
MerkleRootType
Definition: SubCachePluginAdapter.h:167
A SubCachePlugin implementation that wraps a SynchronizedCache.
Definition: SubCachePluginAdapter.h:32
std::integral_constant< MerkleRootType, MerkleRootType::Supported > SupportedMerkleRootFlag
Definition: SubCachePluginAdapter.h:169