CatapultServer  v0.5.0.1 (Elephant)
AccountRestrictions.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/types.h"
24 
25 namespace catapult { namespace state {
26 
29  private:
30  using RestrictionsMap = std::map<model::AccountRestrictionType, AccountRestriction>;
31  using const_iterator = RestrictionsMap::const_iterator;
32 
33  public:
35  explicit AccountRestrictions(const Address& address);
36 
37  public:
39  const Address& address() const;
40 
42  size_t size() const;
43 
45  bool isEmpty() const;
46 
47  public:
49  template<typename TRestrictionValue>
51  const auto& restriction = this->restriction<const RestrictionsMap, const AccountRestriction>(m_restrictions, restrictionType);
53  }
54 
56  const AccountRestriction& restriction(model::AccountRestrictionType restrictionType) const;
57 
60 
61  public:
63  const_iterator begin() const;
64 
66  const_iterator end() const;
67 
68  private:
69  void addRestriction(model::AccountRestrictionType restrictionType, size_t restrictionValueSize);
70 
71  private:
72  template<typename TRestrictionsMap, typename TAccountRestriction>
73  static TAccountRestriction& restriction(TRestrictionsMap& restrictionsMap, model::AccountRestrictionType restrictionType) {
74  auto iter = restrictionsMap.find(AccountRestrictionDescriptor(restrictionType).restrictionType());
75  if (restrictionsMap.cend() == iter)
76  CATAPULT_THROW_INVALID_ARGUMENT_1("unknown account restriction type", static_cast<uint16_t>(restrictionType));
77 
78  return iter->second;
79  }
80 
81  private:
84  };
85 }}
catapult::state::AccountRestrictions::m_address
Address m_address
Definition: AccountRestrictions.h:82
TypedAccountRestriction.h
catapult::validators::DEFINE_ACCOUNT_RESTRICTION_REDUNDANT_MODIFICATION_VALIDATOR
DEFINE_ACCOUNT_RESTRICTION_REDUNDANT_MODIFICATION_VALIDATOR(AccountAddressRestriction, UnresolvedAddress, utils::ArrayHasher< UnresolvedAddress >) DEFINE_ACCOUNT_RESTRICTION_REDUNDANT_MODIFICATION_VALIDATOR(AccountMosaicRestriction
catapult::UnresolvedAddress
utils::ByteArray< Address_Decoded_Size, UnresolvedAddress_tag > UnresolvedAddress
Definition: src/catapult/types.h:66
HasRedundantModification
bool HasRedundantModification
Definition: AccountRestrictionRedundantModificationValidator.cpp:30
catapult::model::AccountRestrictionType
AccountRestrictionType
Account restriction types.
Definition: AccountRestrictionTypes.h:31
AccountRestrictionCache.h
catapult::state::AccountRestriction
Account restriction.
Definition: AccountRestriction.h:29
catapult::state::AccountRestrictions::RestrictionsMap
std::map< model::AccountRestrictionType, AccountRestriction > RestrictionsMap
Definition: AccountRestrictions.h:30
catapult::model::AccountRestrictionType::TransactionType
Account restriction type is a transaction type.
ValidatorContext.h
catapult::validators::ValidationResult
ValidationResult
Enumeration of all possible validation results.
Definition: ValidationResult.h:51
catapult::state::TypedAccountRestriction
Typed account restriction.
Definition: TypedAccountRestriction.h:29
catapult::state::AccountRestrictionDescriptor
Account restriction descriptor.
Definition: AccountRestrictionDescriptor.h:37
catapult::state::AccountRestrictions::size
size_t size() const
Gets the number of possible account restrictions.
Definition: AccountRestrictions.cpp:36
catapult::model::EntityType
EntityType
Enumeration of entity types.
Definition: EntityType.h:43
catapult::state::AccountRestrictions::isEmpty
bool isEmpty() const
Returns true if no restrictions are set.
Definition: AccountRestrictions.cpp:40
catapult::state::AccountRestrictions::restriction
static TAccountRestriction & restriction(TRestrictionsMap &restrictionsMap, model::AccountRestrictionType restrictionType)
Definition: AccountRestrictions.h:73
catapult::state::AccountRestrictions::addRestriction
void addRestriction(model::AccountRestrictionType restrictionType, size_t restrictionValueSize)
Definition: AccountRestrictions.cpp:62
EntityType.h
Value
uint32_t Value
Definition: BlockScorer.cpp:32
catapult::utils::BaseValue< uint64_t, UnresolvedMosaicId_tag >
catapult::state::AccountRestrictions::begin
const_iterator begin() const
Returns a const iterator to the first account restriction.
Definition: AccountRestrictions.cpp:54
catapult::model::AccountRestrictionType::MosaicId
Account restriction type is a mosaic id.
catapult::state::AccountRestrictions::AccountRestrictions
AccountRestrictions(const Address &address)
Creates account restrictions around address.
Definition: AccountRestrictions.cpp:26
catapult::state::AccountRestrictions::m_restrictions
RestrictionsMap m_restrictions
Definition: AccountRestrictions.h:83
HasDeleteModification
bool HasDeleteModification
Definition: AccountRestrictionRedundantModificationValidator.cpp:31
catapult::utils::BaseValueHasher
Hasher object for a base value.
Definition: Hashers.h:43
catapult::state::AccountRestrictions::address
const Address & address() const
Gets the account address.
Definition: AccountRestrictions.cpp:32
Address.h
catapult::state::AccountRestrictions
Account restrictions.
Definition: AccountRestrictions.h:28
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::state::AccountRestrictions::end
const_iterator end() const
Returns a const iterator to the element following the last account restriction.
Definition: AccountRestrictions.cpp:58
catapult::model::PublicKeyToAddress
Address PublicKeyToAddress(const Key &publicKey, NetworkIdentifier networkIdentifier)
Creates an address from a public key (publicKey) for the network identified by networkIdentifier.
Definition: Address.cpp:50
Validators.h
catapult::validators::ValidationResult::Success
Validation succeeded.
catapult::state::AccountRestrictions::restriction
TypedAccountRestriction< TRestrictionValue > restriction(model::AccountRestrictionType restrictionType) const
Gets the const typed account restriction specified by restrictionType.
Definition: AccountRestrictions.h:50
catapult::Address_Decoded_Size
constexpr size_t Address_Decoded_Size
Definition: src/catapult/types.h:59
types.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::ByteArray< Address_Decoded_Size, Address_tag >
catapult::model::AccountRestrictionType::Address
Account restriction type is an address.
catapult::model::CosignatoryModificationType::Del
Remove cosignatory.
catapult::state::AccountRestrictions::const_iterator
RestrictionsMap::const_iterator const_iterator
Definition: AccountRestrictions.h:31
AccountRestrictions.h