CatapultServer  v0.5.0.1 (Elephant)
AccountRestriction.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include <set>
24 #include <vector>
25 
26 namespace catapult { namespace state {
27 
30  public:
32  using RawValue = std::vector<uint8_t>;
33 
34  public:
36  explicit AccountRestriction(model::AccountRestrictionType restrictionType, size_t restrictionValueSize);
37 
38  public:
41 
43  size_t valueSize() const;
44 
46  const std::set<std::vector<uint8_t>>& values() const;
47 
48  public:
50  bool contains(const std::vector<uint8_t>& value) const;
51 
53  bool canAllow(const model::RawAccountRestrictionModification& modification) const;
54 
56  bool canBlock(const model::RawAccountRestrictionModification& modification) const;
57 
58  public:
60  void allow(const model::RawAccountRestrictionModification& modification);
61 
63  void block(const model::RawAccountRestrictionModification& modification);
64 
65  private:
66  bool isOperationAllowed(
67  const model::RawAccountRestrictionModification& modification,
68  AccountRestrictionOperationType operationType) const;
69 
70  void update(const model::RawAccountRestrictionModification& modification);
71 
72  private:
75  std::set<RawValue> m_values;
76  };
77 }}
catapult::model::RawAccountRestrictionModification::ModificationType
AccountRestrictionModificationType ModificationType
Modification type.
Definition: AccountRestrictionTypes.h:76
catapult::state::AccountRestriction::canBlock
bool canBlock(const model::RawAccountRestrictionModification &modification) const
Returns true if modification can be applied to the blocked values.
Definition: AccountRestriction.cpp:50
catapult::model::AccountRestrictionType
AccountRestrictionType
Account restriction types.
Definition: AccountRestrictionTypes.h:31
catapult::state::AccountRestriction::descriptor
const AccountRestrictionDescriptor & descriptor() const
Gets the restriction descriptor.
Definition: AccountRestriction.cpp:30
catapult::state::AccountRestriction
Account restriction.
Definition: AccountRestriction.h:29
catapult::state::AccountRestrictionDescriptor
Account restriction descriptor.
Definition: AccountRestrictionDescriptor.h:37
catapult::state::AccountRestrictionOperationType::Block
Account restriction contains blocked value.
CATAPULT_THROW_INVALID_ARGUMENT_2
#define CATAPULT_THROW_INVALID_ARGUMENT_2(MESSAGE, PARAM1, PARAM2)
Macro used to throw a catapult invalid argument with two parameters.
Definition: exceptions.h:187
catapult::state::AccountRestriction::canAllow
bool canAllow(const model::RawAccountRestrictionModification &modification) const
Returns true if modification can be applied to the allowed values.
Definition: AccountRestriction.cpp:46
catapult::state::AccountRestriction::allow
void allow(const model::RawAccountRestrictionModification &modification)
Applies modification to the allowed values.
Definition: AccountRestriction.cpp:54
catapult::state::AccountRestriction::isOperationAllowed
bool isOperationAllowed(const model::RawAccountRestrictionModification &modification, AccountRestrictionOperationType operationType) const
Definition: AccountRestriction.cpp:67
catapult::state::AccountRestriction::m_restrictionValueSize
size_t m_restrictionValueSize
Definition: AccountRestriction.h:74
catapult::state::AccountRestriction::m_restrictionDescriptor
AccountRestrictionDescriptor m_restrictionDescriptor
Definition: AccountRestriction.h:73
catapult::state::AccountRestriction::update
void update(const model::RawAccountRestrictionModification &modification)
Definition: AccountRestriction.cpp:82
catapult::state::AccountRestrictionDescriptor::operationType
constexpr AccountRestrictionOperationType operationType() const
Gets the operation type.
Definition: AccountRestrictionDescriptor.h:51
catapult::model::AccountRestrictionType::Block
Account restriction is interpreted as blocking operation.
catapult::state::AccountRestriction::contains
bool contains(const std::vector< uint8_t > &value) const
Returns true if value is known.
Definition: AccountRestriction.cpp:42
catapult::model::RawAccountRestrictionModification
Raw account restriction modification.
Definition: AccountRestrictionTypes.h:73
AccountRestrictionDescriptor.h
catapult::state::AccountRestriction::m_values
std::set< RawValue > m_values
Definition: AccountRestriction.h:75
catapult::state::AccountRestrictionOperationType::Allow
Account restriction contains allowed values.
catapult::state::AccountRestrictionOperationType
AccountRestrictionOperationType
Operation type.
Definition: AccountRestrictionDescriptor.h:28
AccountRestriction.h
catapult::state::AccountRestrictionDescriptor::restrictionType
constexpr model::AccountRestrictionType restrictionType() const
Gets the value specific part of the restriction type.
Definition: AccountRestrictionDescriptor.h:46
catapult::model::RawAccountRestrictionModification::Value
std::vector< uint8_t > Value
Restriction value.
Definition: AccountRestrictionTypes.h:79
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::state::AccountRestriction::AccountRestriction
AccountRestriction(model::AccountRestrictionType restrictionType, size_t restrictionValueSize)
Creates an account restriction around restrictionType and restrictionValueSize.
Definition: AccountRestriction.cpp:25
catapult::state::AccountRestriction::valueSize
size_t valueSize() const
Gets the restriction value size.
Definition: AccountRestriction.cpp:34
catapult::state::AccountRestriction::values
const std::set< std::vector< uint8_t > > & values() const
Gets the values.
Definition: AccountRestriction.cpp:38
catapult::state::AccountRestriction::block
void block(const model::RawAccountRestrictionModification &modification)
Applies modification to the the blocked values.
Definition: AccountRestriction.cpp:61
catapult::model::CosignatoryModificationType::Add
Add cosignatory.
catapult::state::AccountRestriction::RawValue
std::vector< uint8_t > RawValue
Raw restriction value.
Definition: AccountRestriction.h:32