CatapultServer  v0.5.0.1 (Elephant)
RootNamespaceHistory.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "RootNamespace.h"
24 #include <boost/optional.hpp>
25 #include <list>
26 #include <set>
27 
28 namespace catapult { namespace state {
29 
32  public:
34  explicit RootNamespaceHistory(NamespaceId id);
35 
39 
41  RootNamespaceHistory(RootNamespaceHistory&& history) = default;
42 
43  public:
44  RootNamespace& operator=(const RootNamespace& rhs) = delete;
45 
46  public:
48  bool empty() const;
49 
51  NamespaceId id() const;
52 
54  size_t historyDepth() const;
55 
57  size_t activeOwnerHistoryDepth() const;
58 
60  size_t numActiveRootChildren() const;
61 
64  size_t numAllHistoricalChildren() const;
65 
66  public:
68  void push_back(const Key& owner, const NamespaceLifetime& lifetime);
69 
71  void pop_back();
72 
74  const RootNamespace& back() const;
75 
78 
80  std::set<NamespaceId> prune(Height height);
81 
82  public:
84  std::list<RootNamespace>::const_iterator begin() const;
85 
87  std::list<RootNamespace>::const_iterator end() const;
88 
89  public:
91  bool isActiveAndUnlocked(Height height) const;
92 
95  bool isActive(Height height) const;
96 
97  private:
99  std::list<RootNamespace> m_rootHistory;
100  };
101 }}
RootNamespaceHistory.h
catapult::state::RootNamespaceHistory::isActive
bool isActive(Height height) const
Definition: RootNamespaceHistory.cpp:146
m_id
size_t m_id
Definition: AuditConsumer.cpp:65
catapult::state::RootNamespaceHistory::m_rootHistory
std::list< RootNamespace > m_rootHistory
Definition: RootNamespaceHistory.h:99
catapult::state::RootNamespace::size
size_t size() const
Gets the number of child namespaces.
Definition: RootNamespace.cpp:61
catapult::state::RootNamespaceHistory::numAllHistoricalChildren
size_t numAllHistoricalChildren() const
Definition: RootNamespaceHistory.cpp:87
catapult::state::NamespaceLifetime::isActiveAndUnlocked
bool isActiveAndUnlocked(Height height) const
Returns true if history is active at height (excluding grace period).
Definition: NamespaceLifetime.cpp:53
catapult::state::RootNamespaceHistory::operator=
RootNamespace & operator=(const RootNamespace &rhs)=delete
catapult::state::RootNamespaceHistory::pop_back
void pop_back()
Removes the last entry in the history.
Definition: RootNamespaceHistory.cpp:104
catapult::state::RootNamespaceHistory
A root namespace history.
Definition: RootNamespaceHistory.h:31
catapult::state::RootNamespaceHistory::m_id
NamespaceId m_id
Definition: RootNamespaceHistory.h:98
catapult::state::RootNamespace::Children
std::unordered_map< NamespaceId, ChildNamespaceData, utils::BaseValueHasher< NamespaceId > > Children
Definition: RootNamespace.h:56
catapult::utils::BaseValue< uint64_t, NamespaceId_tag >
catapult::utils::Sum
auto Sum(const TContainer &container, TFunction accessor)
Definition: Functional.h:39
catapult::state::RootNamespaceHistory::empty
bool empty() const
Gets a value indicating whether or not the history is empty.
Definition: RootNamespaceHistory.cpp:55
RootNamespace.h
catapult::state::RootNamespaceHistory::activeOwnerHistoryDepth
size_t activeOwnerHistoryDepth() const
Gets the number of root namespaces with the same owner starting at the active history.
Definition: RootNamespaceHistory.cpp:67
catapult::state::RootNamespaceHistory::begin
std::list< RootNamespace >::const_iterator begin() const
Returns a const iterator to the first root namespace.
Definition: RootNamespaceHistory.cpp:134
catapult::state::RootNamespaceHistory::back
const RootNamespace & back() const
Gets a const reference to the most recent root namespace.
Definition: RootNamespaceHistory.cpp:108
Functional.h
catapult::state::NamespaceLifetime
Lifetime of a namespace.
Definition: NamespaceLifetime.h:27
catapult::state::NamespaceLifetime::isActiveOrGracePeriod
bool isActiveOrGracePeriod(Height height) const
Returns true if history is active at height (including grace period).
Definition: NamespaceLifetime.cpp:57
AccountState.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::state::RootNamespaceHistory::end
std::list< RootNamespace >::const_iterator end() const
Returns a const iterator to the element following the last root namespace.
Definition: RootNamespaceHistory.cpp:138
catapult::state::RootNamespace::lifetime
const NamespaceLifetime & lifetime() const
Gets a const reference to the lifetime of this namespace.
Definition: RootNamespace.cpp:53
catapult::state::RootNamespaceHistory::historyDepth
size_t historyDepth() const
Gets the root namespace history size.
Definition: RootNamespaceHistory.cpp:63
catapult::state::RootNamespaceHistory::isActiveAndUnlocked
bool isActiveAndUnlocked(Height height) const
Returns true if history is active at height (excluding grace period).
Definition: RootNamespaceHistory.cpp:142
catapult::state::RootNamespaceHistory::RootNamespaceHistory
RootNamespaceHistory(NamespaceId id)
Creates a root namespace history around id.
Definition: RootNamespaceHistory.cpp:38
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::utils::ByteArray< Key_Size, Key_tag >
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::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
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