CatapultServer  v0.5.0.1 (Elephant)
NamespaceCacheDelta.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NamespaceBaseSets.h"
23 #include "NamespaceCacheMixins.h"
28 
29 namespace catapult { namespace cache {
30 
33  private:
36 
37  public:
45 
50  };
51 
54  : public utils::MoveOnly
62  public:
64  using CollectedIds = std::unordered_set<NamespaceId, utils::BaseValueHasher<NamespaceId>>;
65 
66  public:
69  const NamespaceCacheTypes::BaseSetDeltaPointers& namespaceSets,
70  const NamespaceCacheTypes::Options& options,
71  const NamespaceSizes& namespaceSizes);
72 
73  public:
75  void insert(const state::RootNamespace& ns);
76 
78  void insert(const state::Namespace& ns);
79 
81  void setAlias(NamespaceId id, const state::NamespaceAlias& alias);
82 
84  void remove(NamespaceId id);
85 
87  CollectedIds prune(Height height);
88 
89  private:
90  void removeRoot(NamespaceId id);
91  void removeChild(const state::Namespace& ns);
92 
93  private:
95  NamespaceCacheTypes::NamespaceCacheTypes::FlatMapTypes::BaseSetDeltaPointerType m_pNamespaceById;
98  };
99 
101  class NamespaceCacheDelta : public ReadOnlyViewSupplier<BasicNamespaceCacheDelta> {
102  public:
105  const NamespaceCacheTypes::BaseSetDeltaPointers& namespaceSets,
106  const NamespaceCacheTypes::Options& options,
107  const NamespaceSizes& namespaceSizes)
108  : ReadOnlyViewSupplier(namespaceSets, options, namespaceSizes)
109  {}
110  };
111 }}
catapult::state::NamespaceLifetime::End
Height End
End height excluding grace period.
Definition: NamespaceLifetime.h:54
catapult::cache::BasicNamespaceCacheDelta::remove
void remove(NamespaceId id)
Removes the namespace specified by its id from the cache.
Definition: NamespaceCacheDelta.cpp:117
catapult::cache::NamespaceDeepSizeMixin::incrementDeepSize
void incrementDeepSize(size_t delta=1)
Increments the deep size by delta.
Definition: NamespaceCacheMixins.h:69
catapult::cache::BasicCacheMixins::Size
SizeMixin< TSet > Size
Definition: CacheMixinAliases.h:31
catapult::cache::BasicNamespaceCacheDelta
Basic delta on top of the namespace cache.
Definition: NamespaceCacheDelta.h:53
catapult::cache::NamespaceBaseSetDeltaPointers
Definition: NamespaceBaseSets.h:41
catapult::cache::BasicNamespaceCacheDelta::removeRoot
void removeRoot(NamespaceId id)
Definition: NamespaceCacheDelta.cpp:129
catapult::cache::NamespaceCacheDeltaMixins
Mixins used by the namespace delta view.
Definition: NamespaceCacheDelta.h:32
catapult::cache::BasicCacheMixins::DeltaElements
deltaset::DeltaElementsMixin< TSet > DeltaElements
Definition: CacheMixinAliases.h:47
catapult::state::Namespace
A catapult namespace.
Definition: Namespace.h:30
catapult::state::NamespaceLifetime::Start
Height Start
Start height.
Definition: NamespaceLifetime.h:51
catapult::cache::ReadOnlyViewSupplier
Decorates a view and supplies a read-only view.
Definition: ReadOnlyViewSupplier.h:28
catapult::state::Namespace::rootId
NamespaceId rootId() const
Gets the corresponding root namespace id.
Definition: Namespace.h:53
catapult::state::Namespace::id
NamespaceId id() const
Gets the namespace id.
Definition: Namespace.h:43
catapult::cache::RemoveIdentifierWithGroup
void RemoveIdentifierWithGroup(TGroupedSet &groupedSet, const TGroupingKey &key, const TIdentifier &identifier)
Removes an identifier with grouping key from groupedSet.
Definition: IdentifierGroupCacheUtils.h:57
catapult::deltaset::DeltaElementsMixin
Mixin that wraps BaseSetDelta and provides a facade on top of BaseSetDelta::deltas().
Definition: DeltaElementsMixin.h:30
catapult::cache::PatriciaTreeCacheMixins::PatriciaTreeDelta
PatriciaTreeDeltaMixin< TSet, typename TCacheDescriptor::PatriciaTree::DeltaType > PatriciaTreeDelta
Definition: CacheMixinAliases.h:54
catapult::cache::detail::UnorderedMapAdapter::BaseSetDeltaType
typename BaseSetType::DeltaType BaseSetDeltaType
Base set delta type.
Definition: CacheDescriptorAdapters.h:84
catapult::cache::NamespaceDeepSizeMixin::incrementActiveSize
void incrementActiveSize(size_t delta=1)
Increments the active size by delta.
Definition: NamespaceCacheMixins.h:59
catapult::cache::BasicNamespaceCacheDelta::removeChild
void removeChild(const state::Namespace &ns)
Definition: NamespaceCacheDelta.cpp:167
ReadOnlyViewSupplier.h
catapult::utils::CheckedArray< NamespaceId, Namespace_Max_Depth >
catapult::cache::NamespaceDeepSizeMixin
A mixin for calculating the deep size of namespaces.
Definition: NamespaceCacheMixins.h:40
catapult::state::RootNamespaceHistory::numAllHistoricalChildren
size_t numAllHistoricalChildren() const
Definition: RootNamespaceHistory.cpp:87
NamespaceCacheDelta.h
catapult::cache::BasicNamespaceCacheDelta::insert
void insert(const state::RootNamespace &ns)
Inserts the root namespace ns into the cache.
Definition: NamespaceCacheDelta.cpp:60
catapult::state::RootNamespaceHistory
A root namespace history.
Definition: RootNamespaceHistory.h:31
NamespaceCacheSerializers.h
catapult::cache::ForEachIdentifierWithGroup
void ForEachIdentifierWithGroup(TSet &set, const TGroupedSet &groupedSet, const TGroupingKey &key, TAction action)
Calls action for each value in set with grouping key according to groupedSet.
Definition: IdentifierGroupCacheUtils.h:41
NamespaceCacheMixins.h
catapult::cache::BasicNamespaceCacheDelta::BasicNamespaceCacheDelta
BasicNamespaceCacheDelta(const NamespaceCacheTypes::BaseSetDeltaPointers &namespaceSets, const NamespaceCacheTypes::Options &options, const NamespaceSizes &namespaceSizes)
Creates a delta around namespaceSets, options and namespaceSizes.
Definition: NamespaceCacheDelta.cpp:43
catapult::cache::NamespaceCacheDeltaMixins::Size
PrimaryMixins::Size Size
Definition: NamespaceCacheDelta.h:38
catapult::cache::ReadOnlyArtifactCache
A read-only overlay on top of a cache that provides support for contains, get and isActive.
Definition: MosaicCacheTypes.h:42
catapult::cache::NamespaceLookupMixin
Definition: NamespaceCacheMixins.h:85
catapult::state::RootNamespace::Children
std::unordered_map< NamespaceId, ChildNamespaceData, utils::BaseValueHasher< NamespaceId > > Children
Definition: RootNamespace.h:56
catapult::cache::BasicNamespaceCacheDelta::setAlias
void setAlias(NamespaceId id, const state::NamespaceAlias &alias)
Sets an alias for namespace id.
Definition: NamespaceCacheDelta.cpp:106
ReadOnlyArtifactCache.h
catapult::utils::BaseValue< uint64_t, NamespaceId_tag >
catapult::cache::PatriciaTreeCacheMixins
Grouping of all basic and patricia tree cache mixins for a single set.
Definition: CacheMixinAliases.h:52
catapult::state::RootNamespaceHistory::empty
bool empty() const
Gets a value indicating whether or not the history is empty.
Definition: RootNamespaceHistory.cpp:55
NamespaceBaseSets.h
catapult::cache::BasicCacheMixins::Contains
ContainsMixin< TSet, TCacheDescriptor > Contains
Definition: CacheMixinAliases.h:32
catapult::cache::AddIdentifierWithGroup
void AddIdentifierWithGroup(TGroupedSet &groupedSet, const TGroupingKey &key, const TIdentifier &identifier)
Adds an identifier with with grouping key to groupedSet.
Definition: IdentifierGroupCacheUtils.h:30
CATAPULT_THROW_RUNTIME_ERROR_1
#define CATAPULT_THROW_RUNTIME_ERROR_1(MESSAGE, PARAM1)
Macro used to throw a catapult runtime error with a single parameter.
Definition: exceptions.h:171
catapult::cache::BasicNamespaceCacheDelta::CollectedIds
std::unordered_set< NamespaceId, utils::BaseValueHasher< NamespaceId > > CollectedIds
Definition: NamespaceCacheDelta.h:64
catapult::deltaset::BaseSetDelta::insert
InsertResult insert(const ElementType &element)
Definition: BaseSetDelta.h:193
catapult::cache::ContainsMixin
A mixin for adding contains support to a cache.
Definition: CacheMixins.h:54
catapult::state::RootNamespace::id
NamespaceId id() const
Gets the namespace id.
Definition: RootNamespace.cpp:41
catapult::cache::NamespaceCacheDelta
Delta on top of the namespace cache.
Definition: NamespaceCacheDelta.h:101
catapult::state::NamespaceLifetime
Lifetime of a namespace.
Definition: NamespaceLifetime.h:27
catapult::cache::BasicNamespaceCacheDelta::m_pHistoryById
NamespaceCacheTypes::PrimaryTypes::BaseSetDeltaPointerType m_pHistoryById
Definition: NamespaceCacheDelta.h:94
catapult::cache::BasicNamespaceCacheDelta::m_pNamespaceById
NamespaceCacheTypes::NamespaceCacheTypes::FlatMapTypes::BaseSetDeltaPointerType m_pNamespaceById
Definition: NamespaceCacheDelta.h:95
CATAPULT_THROW_INVALID_ARGUMENT_1
#define CATAPULT_THROW_INVALID_ARGUMENT_1(MESSAGE, PARAM1)
Macro used to throw a catapult invalid argument with a single parameter.
Definition: exceptions.h:183
catapult::cache::NamespaceCacheDeltaMixins::DeltaElements
PrimaryMixins::DeltaElements DeltaElements
Definition: NamespaceCacheDelta.h:44
catapult::cache::PatriciaTreeDeltaMixin
A mixin for adding patricia tree support to a delta cache.
Definition: PatriciaTreeCacheMixins.h:62
catapult::state::NamespaceAlias
A namespace alias.
Definition: NamespaceAlias.h:39
catapult::utils::MoveOnly
A class that can be moved but not copied.
Definition: NonCopyable.h:43
CacheMixinAliases.h
catapult::cache::BasicNamespaceCacheDelta::m_pRootNamespaceIdsByExpiryHeight
NamespaceCacheTypes::HeightGroupingTypes::BaseSetDeltaPointerType m_pRootNamespaceIdsByExpiryHeight
Definition: NamespaceCacheDelta.h:96
catapult::cache::BasicNamespaceCacheDelta::prune
CollectedIds prune(Height height)
Prunes the namespace cache at height.
Definition: NamespaceCacheDelta.cpp:186
catapult::cache::NamespaceDeepSizeMixin::decrementDeepSize
void decrementDeepSize(size_t delta=1)
Decrements the deep size by delta.
Definition: NamespaceCacheMixins.h:74
catapult::cache::NamespaceCacheTypes::CacheReadOnlyType
ReadOnlyArtifactCache< BasicNamespaceCacheView, BasicNamespaceCacheDelta, NamespaceId, state::NamespaceEntry > CacheReadOnlyType
Definition: NamespaceCacheTypes.h:84
catapult::cache::HeightBasedTouchMixin
A mixin for height-based touching.
Definition: CacheMixins.h:310
catapult::deltaset::RemoveAll
void RemoveAll(TContainer &container, const TElements &elements)
Removes all elements from the container (pContainer).
Definition: BaseSetUtils.h:45
catapult::utils::CheckedArray::push_back
void push_back(T val)
Definition: CheckedArray.h:51
catapult::cache::NamespaceDeepSizeMixin::decrementActiveSize
void decrementActiveSize(size_t delta=1)
Decrements the active size by delta.
Definition: NamespaceCacheMixins.h:64
Casting.h
catapult::cache::detail::UnorderedMapAdapter::BaseSetDeltaPointerType
std::shared_ptr< BaseSetDeltaType > BaseSetDeltaPointerType
Base set delta pointer type.
Definition: CacheDescriptorAdapters.h:87
IdentifierGroupCacheUtils.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::SizeMixin
A mixin for adding size support to a cache.
Definition: CacheMixins.h:36
catapult::state::RootNamespace::lifetime
const NamespaceLifetime & lifetime() const
Gets a const reference to the lifetime of this namespace.
Definition: RootNamespace.cpp:53
catapult::cache::NamespaceCacheTypes::Options
Custom sub view options.
Definition: NamespaceCacheTypes.h:87
catapult::state::RootNamespaceHistory::historyDepth
size_t historyDepth() const
Gets the root namespace history size.
Definition: RootNamespaceHistory.cpp:63
catapult::state::RootNamespaceHistory::prune
std::set< NamespaceId > prune(Height height)
Prunes all root namespaces that are not active at height.
Definition: RootNamespaceHistory.cpp:116
catapult::cache::NamespaceSizes
Extended namespace sizes.
Definition: NamespaceCacheMixins.h:30
catapult::cache::CacheId::Namespace
catapult::cache::NamespaceCacheDelta::NamespaceCacheDelta
NamespaceCacheDelta(const NamespaceCacheTypes::BaseSetDeltaPointers &namespaceSets, const NamespaceCacheTypes::Options &options, const NamespaceSizes &namespaceSizes)
Creates a delta around namespaceSets, options and namespaceSizes.
Definition: NamespaceCacheDelta.h:104
catapult::state::RootNamespaceHistory::push_back
void push_back(const Key &owner, const NamespaceLifetime &lifetime)
Adds a new root namespace around owner and lifetime at the end of the history.
Definition: RootNamespaceHistory.cpp:91
catapult::state::RootNamespaceHistory::id
NamespaceId id() const
Gets the id of the root namespace history.
Definition: RootNamespaceHistory.cpp:59
catapult::state::RootNamespace
A root namespace.
Definition: RootNamespace.h:31
catapult::state::RootNamespaceHistory::numActiveRootChildren
size_t numActiveRootChildren() const
Gets the number of children of the most recent root namespace.
Definition: RootNamespaceHistory.cpp:83
catapult::cache::BasicCacheMixins
Grouping of all basic cache mixins for a single set.
Definition: CacheMixinAliases.h:30
catapult::state::RootNamespace::owner
const Key & owner() const
Gets a const reference to the owner of this namespace.
Definition: RootNamespace.cpp:49
catapult::cache::BasicNamespaceCacheDelta::m_gracePeriodDuration
BlockDuration m_gracePeriodDuration
Definition: NamespaceCacheDelta.h:97