CatapultServer  v0.5.0.1 (Elephant)
BlockDifficultyCacheDelta.h
Go to the documentation of this file.
1 
21 #pragma once
27 
28 namespace catapult { namespace cache {
29 
31  using BlockDifficultyCacheDeltaMixins = BasicCacheMixins<
34 
37  : public utils::MoveOnly
41  public:
45 
46  public:
49  const BlockDifficultyCacheTypes::BaseSetDeltaPointers& difficultyInfoSets,
50  const BlockDifficultyCacheTypes::Options& options);
51 
52  public:
55 
56  public:
59  // IsBaseSetIterable is not (and should not be) implemented for base set deltas.
60  std::unique_ptr<IterableView> tryMakeIterableView() const;
61 
62  public:
64  void insert(const ValueType& info);
65 
67  void insert(Height height, Timestamp timestamp, Difficulty difficulty);
68 
70  void remove(const ValueType& info);
71 
73  void remove(Height height);
74 
75  public:
78  void prune(Height height);
79 
80  private:
81  void checkInsert(Height height);
82  void checkRemove(Height height) const;
83  Height nextHeight() const;
84 
85  private:
90  };
91 
93  class BlockDifficultyCacheDelta : public ReadOnlyViewSupplier<BasicBlockDifficultyCacheDelta> {
94  public:
97  const BlockDifficultyCacheTypes::BaseSetDeltaPointers& difficultyInfoSets,
99  : ReadOnlyViewSupplier(difficultyInfoSets, options)
100  {}
101  };
102 }}
exceptions.h
catapult::cache::detail::OrderedMemorySetAdapter::BaseSetDeltaType
typename BaseSetType::DeltaType BaseSetDeltaType
Base set delta type.
Definition: CacheDescriptorAdapters.h:137
catapult::cache::BlockDifficultyCacheDeltaMixins
BasicCacheMixins< BlockDifficultyCacheTypes::PrimaryTypes::BaseSetDeltaType, BlockDifficultyCacheDescriptor > BlockDifficultyCacheDeltaMixins
Mixins used by the block difficulty cache delta.
Definition: BlockDifficultyCacheDelta.h:33
catapult::cache::BasicBlockDifficultyCacheDelta::m_startHeight
Height m_startHeight
Definition: BlockDifficultyCacheDelta.h:88
catapult::cache::ReadOnlyViewSupplier
Decorates a view and supplies a read-only view.
Definition: ReadOnlyViewSupplier.h:28
catapult::cache::BlockDifficultyCacheTypes::CacheReadOnlyType
ReadOnlySimpleCache< BasicBlockDifficultyCacheView, BasicBlockDifficultyCacheDelta, state::BlockDifficultyInfo > CacheReadOnlyType
Definition: BlockDifficultyCacheTypes.h:67
catapult::deltaset::DeltaElementsMixin
Mixin that wraps BaseSetDelta and provides a facade on top of BaseSetDelta::deltas().
Definition: DeltaElementsMixin.h:30
catapult::Height
utils::BaseValue< uint64_t, Height_tag > Height
Definition: src/catapult/types.h:85
catapult::cache::BasicBlockDifficultyCacheDelta::BasicBlockDifficultyCacheDelta
BasicBlockDifficultyCacheDelta(const BlockDifficultyCacheTypes::BaseSetDeltaPointers &difficultyInfoSets, const BlockDifficultyCacheTypes::Options &options)
Creates a delta around difficultyInfoSets and options.
Definition: BlockDifficultyCacheDelta.cpp:27
catapult::cache::BlockDifficultyCacheDescriptor
Describes a block difficulty cache.
Definition: BlockDifficultyCacheTypes.h:42
ReadOnlyViewSupplier.h
catapult::cache::BasicBlockDifficultyCacheDelta::m_pOrderedDelta
BlockDifficultyCacheTypes::PrimaryTypes::BaseSetDeltaPointerType m_pOrderedDelta
Definition: BlockDifficultyCacheDelta.h:86
catapult::state::BlockDifficultyInfo
Definition: BlockDifficultyInfo.h:28
catapult::cache::IterationMixin::IterableView
An iterable view of the cache.
Definition: CacheMixins.h:78
catapult::utils::BasicBaseValue::unwrap
constexpr ValueType unwrap() const
Unwraps this value and returns the underlying raw value.
Definition: BaseValue.h:53
catapult::utils::BaseValue< uint64_t, Height_tag >
catapult::cache::SizeMixin::size
size_t size() const
Gets the number of elements in the cache.
Definition: CacheMixins.h:44
BlockDifficultyCacheTypes.h
catapult::cache::ReadOnlySimpleCache
A read-only overlay on top of a cache that provides support for contains.
Definition: HashCacheTypes.h:37
catapult::cache::BlockDifficultyCacheTypes::Options
Custom sub view options.
Definition: BlockDifficultyCacheTypes.h:70
BaseSetDeltaIterationView.h
catapult::cache::ContainsMixin
A mixin for adding contains support to a cache.
Definition: CacheMixins.h:54
catapult::cache::BasicBlockDifficultyCacheDelta::pruningBoundary
deltaset::PruningBoundary< ValueType > pruningBoundary() const
Gets the pruning boundary that is used during commit.
Definition: BlockDifficultyCacheDelta.cpp:40
forwardsValidation.info
def info(*args)
Definition: forwardsValidation.py:12
catapult::cache::detail::OrderedMemorySetAdapter::BaseSetDeltaPointerType
std::shared_ptr< BaseSetDeltaType > BaseSetDeltaPointerType
Base set delta pointer type.
Definition: CacheDescriptorAdapters.h:140
catapult::cache::BasicBlockDifficultyCacheDelta
Basic delta on top of the block difficulty cache.
Definition: BlockDifficultyCacheDelta.h:36
catapult::cache::BasicBlockDifficultyCacheDelta::tryMakeIterableView
std::unique_ptr< IterableView > tryMakeIterableView() const
Definition: BlockDifficultyCacheDelta.cpp:44
catapult::cache::BasicBlockDifficultyCacheDelta::ValueType
BlockDifficultyCacheDescriptor::ValueType ValueType
Definition: BlockDifficultyCacheDelta.h:43
catapult::cache::BlockDifficultyCacheDelta::BlockDifficultyCacheDelta
BlockDifficultyCacheDelta(const BlockDifficultyCacheTypes::BaseSetDeltaPointers &difficultyInfoSets, const BlockDifficultyCacheTypes::Options &options)
Creates a delta around difficultyInfoSets and options.
Definition: BlockDifficultyCacheDelta.h:96
catapult::utils::MoveOnly
A class that can be moved but not copied.
Definition: NonCopyable.h:43
CacheMixinAliases.h
catapult::cache::BlockDifficultyCacheDelta
Delta on top of the block difficulty cache.
Definition: BlockDifficultyCacheDelta.h:93
CATAPULT_THROW_RUNTIME_ERROR
#define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE)
Macro used to throw a catapult runtime error.
Definition: exceptions.h:167
catapult::cache::BasicBlockDifficultyCacheDelta::m_pruningBoundary
deltaset::PruningBoundary< ValueType > m_pruningBoundary
Definition: BlockDifficultyCacheDelta.h:89
catapult::cache::BasicBlockDifficultyCacheDelta::m_difficultyHistorySize
uint64_t m_difficultyHistorySize
Definition: BlockDifficultyCacheDelta.h:87
catapult::cache::BasicBlockDifficultyCacheDelta::remove
void remove(const ValueType &info)
Removes a block difficulty info from the set.
Definition: BlockDifficultyCacheDelta.cpp:58
catapult::cache::BasicBlockDifficultyCacheDelta::nextHeight
Height nextHeight() const
Definition: BlockDifficultyCacheDelta.cpp:109
ReadOnlySimpleCache.h
CATAPULT_THROW_INVALID_ARGUMENT
#define CATAPULT_THROW_INVALID_ARGUMENT(MESSAGE)
Macro used to throw a catapult invalid argument.
Definition: exceptions.h:179
catapult::deltaset::PruningBoundary
Represents an optional pruning boundary.
Definition: PruningBoundary.h:27
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::ClampedBaseValue< uint64_t, Difficulty_tag >
catapult::cache::SizeMixin
A mixin for adding size support to a cache.
Definition: CacheMixins.h:36
catapult::cache::BasicBlockDifficultyCacheDelta::insert
void insert(const ValueType &info)
Inserts a block difficulty info into the set.
Definition: BlockDifficultyCacheDelta.cpp:48
catapult::cache::BasicBlockDifficultyCacheDelta::checkRemove
void checkRemove(Height height) const
Definition: BlockDifficultyCacheDelta.cpp:98
catapult::deltaset::MakeIterableView
BaseSetDeltaIterationView< TSetTraits > MakeIterableView(const BaseSetDelta< TElementTraits, TSetTraits > &delta)
Definition: BaseSetDeltaIterationView.h:200
catapult::cache::BasicBlockDifficultyCacheDelta::checkInsert
void checkInsert(Height height)
Definition: BlockDifficultyCacheDelta.cpp:85
BaseSetDelta.h
catapult::cache::BasicBlockDifficultyCacheDelta::prune
void prune(Height height)
Definition: BlockDifficultyCacheDelta.cpp:68
catapult::cache::BasicCacheMixins
Grouping of all basic cache mixins for a single set.
Definition: CacheMixinAliases.h:30
catapult::cache::BlockDifficultyCacheDescriptor::ValueType
KeyType ValueType
Definition: BlockDifficultyCacheTypes.h:46
BlockDifficultyCacheDelta.h