CatapultServer  v0.5.0.1 (Elephant)
NamespaceNotifications.h
Go to the documentation of this file.
1 
21 #pragma once
25 
26 namespace catapult { namespace model {
27 
28  // region namespace notification types
29 
31 #define DEFINE_NAMESPACE_NOTIFICATION(DESCRIPTION, CODE, CHANNEL) DEFINE_NOTIFICATION_TYPE(CHANNEL, Namespace, DESCRIPTION, CODE)
32 
34  DEFINE_NAMESPACE_NOTIFICATION(Name, 0x0011, Validator);
35 
37  DEFINE_NAMESPACE_NOTIFICATION(Registration, 0x0012, Validator);
38 
40  DEFINE_NAMESPACE_NOTIFICATION(Root_Registration, 0x0021, All);
41 
43  DEFINE_NAMESPACE_NOTIFICATION(Child_Registration, 0x0022, All);
44 
46  DEFINE_NAMESPACE_NOTIFICATION(Rental_Fee, 0x0030, Observer);
47 
48 #undef DEFINE_NAMESPACE_NOTIFICATION
49 
50  // endregion
51 
52  // region NamespaceNameNotification
53 
56  public:
58  static constexpr auto Notification_Type = Namespace_Name_Notification;
59 
60  public:
63  catapult::NamespaceId namespaceId,
64  catapult::NamespaceId parentId,
65  uint8_t nameSize,
66  const uint8_t* pName)
68  , NamespaceId(namespaceId)
69  , ParentId(parentId)
70  , NameSize(nameSize)
71  , NamePtr(pName)
72  {}
73 
74  public:
77 
80 
82  uint8_t NameSize;
83 
85  const uint8_t* NamePtr;
86  };
87 
88  // endregion
89 
90  // region NamespaceNotification
91 
94  public:
96  static constexpr auto Notification_Type = Namespace_Registration_Notification;
97 
98  public:
102  , NamespaceType(namespaceType)
103  {}
104 
105  public:
108  };
109 
110  // endregion
111 
112  // region RootNamespaceNotification
113 
116  public:
118  static constexpr auto Notification_Type = Namespace_Root_Registration_Notification;
119 
120  public:
122  RootNamespaceNotification(const Key& signer, NamespaceId namespaceId, BlockDuration duration)
124  , Signer(signer)
125  , NamespaceId(namespaceId)
126  , Duration(duration)
127  {}
128 
129  public:
131  const Key& Signer;
132 
135 
138  };
139 
140  // endregion
141 
142  // region ChildNamespaceNotification
143 
146  public:
148  static constexpr auto Notification_Type = Namespace_Child_Registration_Notification;
149 
150  public:
152  ChildNamespaceNotification(const Key& signer, NamespaceId namespaceId, NamespaceId parentId)
154  , Signer(signer)
155  , NamespaceId(namespaceId)
156  , ParentId(parentId)
157  {}
158 
159  public:
161  const Key& Signer;
162 
165 
168  };
169 
170  // endregion
171 
172  // region NamespaceRentalFeeNotification
173 
175  struct NamespaceRentalFeeNotification : public BasicBalanceNotification<NamespaceRentalFeeNotification> {
176  public:
178  static constexpr auto Notification_Type = Namespace_Rental_Fee_Notification;
179 
180  public:
183  const Key& sender,
184  const UnresolvedAddress& recipient,
185  UnresolvedMosaicId mosaicId,
186  catapult::Amount amount)
187  : BasicBalanceNotification(sender, mosaicId, amount)
188  , Recipient(recipient)
189  {}
190 
191  public:
194  };
195 
196  // endregion
197 }}
NamespaceConstants.h
catapult::validators::reservedRootNamespaceNames
const NameSet & reservedRootNamespaceNames
Definition: NamespaceNameValidator.cpp:31
catapult::Namespace_Base_Id
constexpr NamespaceId Namespace_Base_Id(0)
Base id for namespaces.
catapult::model::ChildNamespaceNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: NamespaceNotifications.h:148
NameChecker.h
catapult::validators::Notification
model::AccountAddressNotification Notification
Definition: AddressValidator.cpp:27
catapult::model::RootNamespaceNotification::Duration
BlockDuration Duration
Number of blocks for which the namespace should be valid.
Definition: NamespaceNotifications.h:137
catapult::model::NamespaceNameNotification::NamespaceNameNotification
NamespaceNameNotification(catapult::NamespaceId namespaceId, catapult::NamespaceId parentId, uint8_t nameSize, const uint8_t *pName)
Creates a notification around nameSize and pName given namespaceId and parentId.
Definition: NamespaceNotifications.h:62
catapult::model::RootNamespaceNotification::NamespaceId
catapult::NamespaceId NamespaceId
Id of the namespace.
Definition: NamespaceNotifications.h:134
catapult::model::NamespaceRentalFeeNotification::Recipient
UnresolvedAddress Recipient
Recipient.
Definition: NamespaceNotifications.h:193
catapult::model::ChildNamespaceNotification::NamespaceId
catapult::NamespaceId NamespaceId
Id of the namespace.
Definition: NamespaceNotifications.h:164
catapult::model::NamespaceNotification::NamespaceNotification
NamespaceNotification(model::NamespaceType namespaceType)
Creates a notification around namespaceType.
Definition: NamespaceNotifications.h:100
catapult::model::RootNamespaceNotification::RootNamespaceNotification
RootNamespaceNotification(const Key &signer, NamespaceId namespaceId, BlockDuration duration)
Creates a notification around signer, namespaceId and duration.
Definition: NamespaceNotifications.h:122
catapult::model::NamespaceNameNotification::NamespaceId
catapult::NamespaceId NamespaceId
Id of the namespace.
Definition: NamespaceNotifications.h:76
catapult::model::ChildNamespaceNotification::ChildNamespaceNotification
ChildNamespaceNotification(const Key &signer, NamespaceId namespaceId, NamespaceId parentId)
Creates a notification around signer, namespaceId and parentId.
Definition: NamespaceNotifications.h:152
catapult::model::RootNamespaceNotification::Signer
const Key & Signer
Signer.
Definition: NamespaceNotifications.h:131
catapult::model::BasicBalanceNotification
A basic balance notification.
Definition: Notifications.h:98
catapult::utils::BaseValue< uint64_t, NamespaceId_tag >
catapult::model::ChildNamespaceNotification
Notification of a child namespace registration.
Definition: NamespaceNotifications.h:145
catapult::model::ChildNamespaceNotification::ParentId
catapult::NamespaceId ParentId
Id of the parent namespace.
Definition: NamespaceNotifications.h:167
catapult::model::NamespaceNotification
Notification of a namespace registration.
Definition: NamespaceNotifications.h:93
catapult::validators::MAKE_STATELESS_VALIDATOR
for(const auto &name :reservedRootNamespaceNames) reservedRootIds.emplace(model return MAKE_STATELESS_VALIDATOR(NamespaceName,([maxNameSize, reservedRootIds](const auto &notification) { if(maxNameSize< notification.NameSize||!model::IsValidName(notification.NamePtr, notification.NameSize)) return Failure_Namespace_Invalid_Name;auto name=utils::RawString(reinterpret_cast< const char * >(notification.NamePtr), notification.NameSize);if(notification.NamespaceId !=model::GenerateNamespaceId(notification.ParentId, name)) return Failure_Namespace_Name_Id_Mismatch;auto namespaceId=Namespace_Base_Id==notification.ParentId ? notification.NamespaceId :notification.ParentId;if(reservedRootIds.cend() !=reservedRootIds.find(namespaceId)) return Failure_Namespace_Root_Name_Reserved;return ValidationResult::Success;}))
Definition: NamespaceNameValidator.cpp:36
catapult::model::NamespaceType
NamespaceType
Namespace types.
Definition: NamespaceTypes.h:27
catapult::model::NamespaceNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: NamespaceNotifications.h:96
catapult::model::NamespaceNameNotification::ParentId
catapult::NamespaceId ParentId
Id of the parent namespace.
Definition: NamespaceNotifications.h:79
catapult::model::IsValidName
bool IsValidName(const uint8_t *pName, size_t nameSize)
Returns true if pName with size nameSize points to a valid name.
Definition: NameChecker.cpp:36
catapult::model::NamespaceRentalFeeNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: NamespaceNotifications.h:178
catapult::model::RootNamespaceNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: NamespaceNotifications.h:118
NamespaceTypes.h
catapult::model::ChildNamespaceNotification::Signer
const Key & Signer
Signer.
Definition: NamespaceNotifications.h:161
Validators.h
Notifications.h
Name
static constexpr auto Name
Definition: PtSynchronizer.cpp:31
catapult::utils::RawString
A const string buffer.
Definition: RawBuffer.h:68
catapult::model::NamespaceNameNotification::NameSize
uint8_t NameSize
Size of the name.
Definition: NamespaceNotifications.h:82
NamespaceIdGenerator.h
catapult::model::Notification
A basic notification.
Definition: Notifications.h:36
catapult::validators::ValidationResult::Success
Validation succeeded.
catapult::model::GenerateNamespaceId
NamespaceId GenerateNamespaceId(NamespaceId parentId, const RawString &name) noexcept
Generates a namespace id given parentId and namespace name.
Definition: NamespaceIdGenerator.cpp:31
catapult::model::NamespaceRentalFeeNotification::NamespaceRentalFeeNotification
NamespaceRentalFeeNotification(const Key &sender, const UnresolvedAddress &recipient, UnresolvedMosaicId mosaicId, catapult::Amount amount)
Creates a notification around sender, recipient, mosaicId and amount.
Definition: NamespaceNotifications.h:182
catapult::model::DEFINE_NAMESPACE_NOTIFICATION
DEFINE_NAMESPACE_NOTIFICATION(Alias_Owner, 0x0081, Validator)
Alias owner was provided.
catapult::validators::DECLARE_STATELESS_VALIDATOR
DECLARE_STATELESS_VALIDATOR(MaxTransactions, Notification)(uint32_t maxTransactions)
Definition: MaxTransactionsValidator.cpp:27
catapult::model::NamespaceNameNotification
Notification of a namespace name.
Definition: NamespaceNotifications.h:55
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::NamespaceRentalFeeNotification
Notification of a namespace rental fee.
Definition: NamespaceNotifications.h:175
catapult::model::AccountAddressNotification
Notification of use of an account address.
Definition: Notifications.h:57
Hashers.h
catapult::model::NamespaceNotification::NamespaceType
model::NamespaceType NamespaceType
Type of the registered namespace.
Definition: NamespaceNotifications.h:107
catapult::validators::NameSet
std::unordered_set< std::string > NameSet
Definition: NamespaceNameValidator.cpp:29
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::model::RootNamespaceNotification
Notification of a root namespace registration.
Definition: NamespaceNotifications.h:115
catapult::model::NamespaceNameNotification::NamePtr
const uint8_t * NamePtr
Const pointer to the namespace name.
Definition: NamespaceNotifications.h:85
catapult::model::NamespaceNameNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: NamespaceNotifications.h:58