CatapultServer  v0.5.0.1 (Elephant)
Notifications.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ContainerTypes.h"
23 #include "EntityType.h"
24 #include "NetworkInfo.h"
25 #include "NotificationType.h"
28 #include "catapult/types.h"
29 #include <vector>
30 
31 namespace catapult { namespace model {
32 
33  // region base notification
34 
36  struct Notification {
37  public:
39  explicit Notification(NotificationType type, size_t size)
40  : Type(type)
41  , Size(size)
42  {}
43 
44  public:
47 
49  size_t Size;
50  };
51 
52  // endregion
53 
54  // region account
55 
58  public:
60  static constexpr auto Notification_Type = Core_Register_Account_Address_Notification;
61 
62  public:
66  , Address(address)
67  {}
68 
69  public:
72  };
73 
76  public:
78  static constexpr auto Notification_Type = Core_Register_Account_Public_Key_Notification;
79 
80  public:
82  explicit AccountPublicKeyNotification(const Key& publicKey)
84  , PublicKey(publicKey)
85  {}
86 
87  public:
89  const Key& PublicKey;
90  };
91 
92  // endregion
93 
94  // region balance
95 
97  template<typename TDerivedNotification>
99  public:
101  BasicBalanceNotification(const Key& sender, UnresolvedMosaicId mosaicId, Amount amount)
102  : Notification(TDerivedNotification::Notification_Type, sizeof(TDerivedNotification))
103  , Sender(sender)
104  , MosaicId(mosaicId)
105  , Amount(amount)
106  {}
107 
108  public:
110  const Key& Sender;
111 
114 
117  };
118 
120  struct BalanceTransferNotification : public BasicBalanceNotification<BalanceTransferNotification> {
121  public:
123  static constexpr auto Notification_Type = Core_Balance_Transfer_Notification;
124 
125  public:
128  const Key& sender,
129  const UnresolvedAddress& recipient,
130  UnresolvedMosaicId mosaicId,
131  catapult::Amount amount)
132  : BasicBalanceNotification(sender, mosaicId, amount)
133  , Recipient(recipient)
134  {}
135 
136  public:
139  };
140 
142  struct BalanceDebitNotification : public BasicBalanceNotification<BalanceDebitNotification> {
143  public:
145  static constexpr auto Notification_Type = Core_Balance_Debit_Notification;
146 
147  public:
149  };
150 
151  // endregion
152 
153  // region entity
154 
157  public:
159  static constexpr auto Notification_Type = Core_Entity_Notification;
160 
161  public:
163  EntityNotification(model::NetworkIdentifier networkIdentifier, uint8_t entityVersion, uint8_t minVersion, uint8_t maxVersion)
165  , NetworkIdentifier(networkIdentifier)
166  , EntityVersion(entityVersion)
167  , MinVersion(minVersion)
168  , MaxVersion(maxVersion)
169  {}
170 
171  public:
174 
176  uint8_t EntityVersion;
177 
179  uint8_t MinVersion;
180 
182  uint8_t MaxVersion;
183  };
184 
185  // endregion
186 
187  // region block
188 
190  struct BlockNotification : public Notification {
191  public:
193  static constexpr auto Notification_Type = Core_Block_Notification;
194 
195  public:
197  BlockNotification(const Key& signer, const Key& beneficiary, Timestamp timestamp, Difficulty difficulty)
199  , Signer(signer)
200  , Beneficiary(beneficiary)
201  , Timestamp(timestamp)
202  , Difficulty(difficulty)
203  , NumTransactions(0)
204  {}
205 
206  public:
208  const Key& Signer;
209 
211  const Key& Beneficiary;
212 
215 
218 
221 
223  uint32_t NumTransactions;
224  };
225 
226  // endregion
227 
228  // region transaction
229 
232  public:
234  static constexpr auto Notification_Type = Core_Transaction_Notification;
235 
236  public:
238  TransactionNotification(const Key& signer, const Hash256& transactionHash, EntityType transactionType, Timestamp deadline)
240  , Signer(signer)
241  , TransactionHash(transactionHash)
242  , TransactionType(transactionType)
243  , Deadline(deadline)
244  {}
245 
246  public:
248  const Key& Signer;
249 
252 
255 
258  };
259 
262  public:
264  static constexpr auto Notification_Type = Core_Transaction_Deadline_Notification;
265 
266  public:
270  , Deadline(deadline)
271  , MaxLifetime(maxLifetime)
272  {}
273 
274  public:
277 
281  };
282 
285  public:
287  static constexpr auto Notification_Type = Core_Transaction_Fee_Notification;
288 
289  public:
291  TransactionFeeNotification(const Key& signer, uint32_t transactionSize, Amount fee, Amount maxFee)
293  , Signer(signer)
294  , TransactionSize(transactionSize)
295  , Fee(fee)
296  , MaxFee(maxFee)
297  {}
298 
299  public:
301  const Key& Signer;
302 
304  uint32_t TransactionSize;
305 
308 
309  // Maximum transaction fee.
311  };
312 
313  // endregion
314 
315  // region signature
316 
319  public:
322 
323  public:
325  static constexpr auto Notification_Type = Core_Signature_Notification;
326 
327  public:
331  const Key& signer,
332  const Signature& signature,
333  const RawBuffer& data,
334  ReplayProtectionMode dataReplayProtectionMode = ReplayProtectionMode::Disabled)
336  , Signer(signer)
337  , Signature(signature)
338  , Data(data)
339  , DataReplayProtectionMode(dataReplayProtectionMode)
340  {}
341 
342  public:
344  const Key& Signer;
345 
348 
351 
354  };
355 
356  // endregion
357 
358  // region address interaction
359 
363  public:
365  static constexpr auto Notification_Type = Core_Address_Interaction_Notification;
366 
367  public:
369  AddressInteractionNotification(const Key& source, EntityType transactionType, const UnresolvedAddressSet& participantsByAddress)
370  : AddressInteractionNotification(source, transactionType, participantsByAddress, {})
371  {}
372 
375  const Key& source,
376  EntityType transactionType,
377  const UnresolvedAddressSet& participantsByAddress,
378  const utils::KeySet& participantsByKey)
380  , Source(source)
381  , TransactionType(transactionType)
382  , ParticipantsByAddress(participantsByAddress)
383  , ParticipantsByKey(participantsByKey)
384  {}
385 
386  public:
389 
392 
395 
398  };
399 
400  // endregion
401 
402  // region mosaic required
403 
406  public:
408  enum class MosaicType { Resolved, Unresolved };
409 
410  public:
412  static constexpr auto Notification_Type = Core_Mosaic_Required_Notification;
413 
414  public:
416  MosaicRequiredNotification(const Key& signer, MosaicId mosaicId)
418  , Signer(signer)
419  , MosaicId(mosaicId)
420  , ProvidedMosaicType(MosaicType::Resolved)
421  {}
422 
426  , Signer(signer)
427  , UnresolvedMosaicId(mosaicId)
428  , ProvidedMosaicType(MosaicType::Unresolved)
429  {}
430 
431  public:
433  const Key& Signer;
434 
437 
440 
443  };
444 
445  // endregion
446 
447  // region source change
448 
451  public:
454 
455  public:
457  static constexpr auto Notification_Type = Core_Source_Change_Notification;
458 
459  public:
462  SourceChangeType primaryChangeType,
463  uint32_t primaryId,
464  SourceChangeType secondaryChangeType,
465  uint32_t secondaryId)
467  , PrimaryChangeType(primaryChangeType)
468  , PrimaryId(primaryId)
469  , SecondaryChangeType(secondaryChangeType)
470  , SecondaryId(secondaryId)
471  {}
472 
473  public:
476 
478  uint32_t PrimaryId;
479 
482 
484  uint32_t SecondaryId;
485  };
486 
487  // endregion
488 }}
catapult::model::TransactionDeadlineNotification::TransactionDeadlineNotification
TransactionDeadlineNotification(Timestamp deadline, utils::TimeSpan maxLifetime)
Creates a transaction deadline notification around deadline and maxLifetime.
Definition: Notifications.h:268
catapult::model::SourceChangeNotification::SourceChangeType
SourceChangeType
Source change types.
Definition: Notifications.h:453
catapult::model::SignatureNotification::Data
RawBuffer Data
Signed data.
Definition: Notifications.h:350
catapult::model::TransactionNotification
Notifies the arrival of a transaction.
Definition: Notifications.h:231
catapult::model::SourceChangeNotification
Notification of a source change.
Definition: Notifications.h:450
catapult::model::SignatureNotification::SignatureNotification
SignatureNotification(const Key &signer, const Signature &signature, const RawBuffer &data, ReplayProtectionMode dataReplayProtectionMode=ReplayProtectionMode::Disabled)
Definition: Notifications.h:330
catapult::model::BasicBalanceNotification::BasicBalanceNotification
BasicBalanceNotification(const Key &sender, UnresolvedMosaicId mosaicId, Amount amount)
Creates a notification around sender, mosaicId and amount.
Definition: Notifications.h:101
catapult::model::BlockNotification::BlockNotification
BlockNotification(const Key &signer, const Key &beneficiary, Timestamp timestamp, Difficulty difficulty)
Creates a block notification around signer, beneficiary, timestamp and difficulty.
Definition: Notifications.h:197
catapult::model::EntityNotification::MinVersion
uint8_t MinVersion
Minimum supported version.
Definition: Notifications.h:179
catapult::model::TransactionFeeNotification::Fee
Amount Fee
Transaction fee.
Definition: Notifications.h:307
catapult::model::EntityNotification::EntityVersion
uint8_t EntityVersion
Entity version.
Definition: Notifications.h:176
catapult::model::SourceChangeNotification::SecondaryId
uint32_t SecondaryId
Secondary source (e.g. index within aggregate).
Definition: Notifications.h:484
catapult::model::AddressInteractionNotification::Source
Key Source
Source.
Definition: Notifications.h:388
catapult::model::BlockNotification::Signer
const Key & Signer
Block signer.
Definition: Notifications.h:208
catapult::model::TransactionNotification::Deadline
Timestamp Deadline
Transaction deadline.
Definition: Notifications.h:257
catapult::model::AddressInteractionNotification::TransactionType
EntityType TransactionType
Transaction type.
Definition: Notifications.h:391
catapult::model::MosaicRequiredNotification::MosaicType
MosaicType
Mosaic types.
Definition: Notifications.h:408
catapult::model::EntityNotification::EntityNotification
EntityNotification(model::NetworkIdentifier networkIdentifier, uint8_t entityVersion, uint8_t minVersion, uint8_t maxVersion)
Creates an entity notification around networkIdentifier, entityVersion, minVersion and maxVersion.
Definition: Notifications.h:163
catapult::model::SignatureNotification::Signer
const Key & Signer
Signer.
Definition: Notifications.h:344
catapult::model::MosaicRequiredNotification
Notification of a required mosaic.
Definition: Notifications.h:405
catapult::model::EntityNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:159
catapult::model::EntityNotification
Notifies the arrival of an entity.
Definition: Notifications.h:156
catapult::model::EntityType
EntityType
Enumeration of entity types.
Definition: EntityType.h:43
catapult::model::BasicBalanceNotification::MosaicId
UnresolvedMosaicId MosaicId
Mosaic id.
Definition: Notifications.h:113
catapult::model::MosaicRequiredNotification::MosaicType::Unresolved
catapult::model::BalanceDebitNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:145
catapult::model::AddressInteractionNotification::AddressInteractionNotification
AddressInteractionNotification(const Key &source, EntityType transactionType, const UnresolvedAddressSet &participantsByAddress)
Creates a notification around source, transactionType and participantsByAddress.
Definition: Notifications.h:369
catapult::model::SignatureNotification::DataReplayProtectionMode
ReplayProtectionMode DataReplayProtectionMode
Replay protection mode applied to data.
Definition: Notifications.h:353
catapult::utils::TimeSpan
Represents a time duration.
Definition: TimeSpan.h:30
catapult::model::TransactionFeeNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:287
catapult::model::BalanceTransferNotification
Notifies a balance transfer from sender to recipient.
Definition: Notifications.h:120
catapult::model::AccountAddressNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:60
catapult::model::BlockNotification::NumTransactions
uint32_t NumTransactions
Number of block transactions.
Definition: Notifications.h:223
EntityType.h
catapult::model::SignatureNotification::ReplayProtectionMode::Disabled
catapult::model::TransactionNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:234
catapult::model::BasicBalanceNotification
A basic balance notification.
Definition: Notifications.h:98
catapult::utils::BaseValue< uint64_t, UnresolvedMosaicId_tag >
catapult::model::MosaicRequiredNotification::MosaicId
catapult::MosaicId MosaicId
Mosaic id (resolved).
Definition: Notifications.h:436
catapult::model::AddressInteractionNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:365
catapult::model::SignatureNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:325
catapult::model::BlockNotification::Beneficiary
const Key & Beneficiary
Beneficiary.
Definition: Notifications.h:211
NetworkInfo.h
catapult::model::AccountAddressNotification::AccountAddressNotification
AccountAddressNotification(const UnresolvedAddress &address)
Creates a notification around address.
Definition: Notifications.h:64
catapult::model::BalanceTransferNotification::Recipient
UnresolvedAddress Recipient
Recipient.
Definition: Notifications.h:138
catapult::model::MosaicRequiredNotification::UnresolvedMosaicId
catapult::UnresolvedMosaicId UnresolvedMosaicId
Mosaic id (unresolved).
Definition: Notifications.h:439
catapult::model::TransactionFeeNotification::TransactionSize
uint32_t TransactionSize
Transaction size.
Definition: Notifications.h:304
catapult::model::SignatureNotification::Signature
const catapult::Signature & Signature
Signature.
Definition: Notifications.h:347
catapult::model::SourceChangeNotification::SecondaryChangeType
SourceChangeType SecondaryChangeType
Type of secondary source change.
Definition: Notifications.h:481
catapult::model::AccountAddressNotification::Address
UnresolvedAddress Address
Address.
Definition: Notifications.h:71
catapult::model::Notification::Type
NotificationType Type
Notification type.
Definition: Notifications.h:46
catapult::model::EntityNotification::NetworkIdentifier
model::NetworkIdentifier NetworkIdentifier
Network identifier.
Definition: Notifications.h:173
catapult::model::TransactionDeadlineNotification::MaxLifetime
utils::TimeSpan MaxLifetime
Definition: Notifications.h:280
catapult::model::MosaicRequiredNotification::MosaicRequiredNotification
MosaicRequiredNotification(const Key &signer, UnresolvedMosaicId mosaicId)
Creates a notification around signer and mosaicId.
Definition: Notifications.h:424
catapult::model::BlockNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:193
catapult::model::NotificationType
NotificationType
Enumeration of all possible notification types.
Definition: NotificationType.h:43
catapult::model::BalanceTransferNotification::BalanceTransferNotification
BalanceTransferNotification(const Key &sender, const UnresolvedAddress &recipient, UnresolvedMosaicId mosaicId, catapult::Amount amount)
Creates a notification around sender, recipient, mosaicId and amount.
Definition: Notifications.h:127
catapult::model::BalanceTransferNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:123
catapult::model::TransactionFeeNotification::Signer
const Key & Signer
Transaction signer.
Definition: Notifications.h:301
catapult::model::TransactionNotification::TransactionHash
const Hash256 & TransactionHash
Transaction hash.
Definition: Notifications.h:251
catapult::model::AddressInteractionNotification::ParticipantsByAddress
UnresolvedAddressSet ParticipantsByAddress
Participants given by address.
Definition: Notifications.h:394
catapult::utils::KeySet
ArraySet< Key > KeySet
A key set.
Definition: ArraySet.h:64
catapult::model::MosaicRequiredNotification::MosaicRequiredNotification
MosaicRequiredNotification(const Key &signer, MosaicId mosaicId)
Creates a notification around signer and mosaicId.
Definition: Notifications.h:416
catapult::model::UnresolvedAddressSet
std::unordered_set< UnresolvedAddress, utils::ArrayHasher< UnresolvedAddress > > UnresolvedAddressSet
Unordered set of unresolved addresses.
Definition: ContainerTypes.h:44
catapult::model::BasicBalanceNotification::Sender
const Key & Sender
Sender.
Definition: Notifications.h:110
catapult::model::SourceChangeNotification::SourceChangeType::Absolute
size
uint64_t size
Definition: MemoryCounters.cpp:65
catapult::model::SignatureNotification::ReplayProtectionMode::Enabled
catapult::model::Notification::Notification
Notification(NotificationType type, size_t size)
Creates a new notification with type and size.
Definition: Notifications.h:39
catapult::model::AccountPublicKeyNotification::AccountPublicKeyNotification
AccountPublicKeyNotification(const Key &publicKey)
Creates a notification around publicKey.
Definition: Notifications.h:82
catapult::model::MosaicRequiredNotification::MosaicType::Resolved
catapult::model::NetworkIdentifier
NetworkIdentifier
Possible network identifiers.
Definition: NetworkInfo.h:45
catapult::model::BlockNotification::Timestamp
catapult::Timestamp Timestamp
Block timestamp.
Definition: Notifications.h:214
catapult::model::MosaicRequiredNotification::ProvidedMosaicType
MosaicType ProvidedMosaicType
Type of mosaic provided and attached to this notification.
Definition: Notifications.h:442
TimeSpan.h
catapult::model::SourceChangeNotification::PrimaryId
uint32_t PrimaryId
Primary source (e.g. index within block).
Definition: Notifications.h:478
NotificationType.h
catapult::model::Notification
A basic notification.
Definition: Notifications.h:36
catapult::model::SourceChangeNotification::SourceChangeNotification
SourceChangeNotification(SourceChangeType primaryChangeType, uint32_t primaryId, SourceChangeType secondaryChangeType, uint32_t secondaryId)
Creates a notification around primaryChangeType, primaryId, secondaryChangeType and secondaryId.
Definition: Notifications.h:461
catapult::model::BlockNotification
Notifies the arrival of a block.
Definition: Notifications.h:190
ContainerTypes.h
catapult::model::SignatureNotification::ReplayProtectionMode
ReplayProtectionMode
Replay protection modes.
Definition: Notifications.h:321
catapult::model::BlockNotification::TotalFee
Amount TotalFee
Total block fee.
Definition: Notifications.h:220
ArraySet.h
catapult::model::EntityNotification::MaxVersion
uint8_t MaxVersion
Maximum supported version.
Definition: Notifications.h:182
types.h
catapult::model::AccountPublicKeyNotification
Notification of use of an account public key.
Definition: Notifications.h:75
catapult::model::TransactionFeeNotification
Notifies the arrival of a transaction fee.
Definition: Notifications.h:284
catapult::model::BlockNotification::Difficulty
catapult::Difficulty Difficulty
Block difficulty.
Definition: Notifications.h:217
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::model::TransactionNotification::Signer
const Key & Signer
Transaction signer.
Definition: Notifications.h:248
catapult::model::TransactionDeadlineNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:264
catapult::utils::ClampedBaseValue< uint64_t, Difficulty_tag >
catapult::model::AccountAddressNotification
Notification of use of an account address.
Definition: Notifications.h:57
catapult::model::BalanceDebitNotification
Notifies a balance debit by sender.
Definition: Notifications.h:142
catapult::model::AddressInteractionNotification::ParticipantsByKey
utils::KeySet ParticipantsByKey
Participants given by public key.
Definition: Notifications.h:397
catapult::model::AccountPublicKeyNotification::PublicKey
const Key & PublicKey
Public key.
Definition: Notifications.h:89
catapult::model::SourceChangeNotification::PrimaryChangeType
SourceChangeType PrimaryChangeType
Type of primary source change.
Definition: Notifications.h:475
catapult::model::SourceChangeNotification::SourceChangeType::Relative
catapult::model::Notification::Size
size_t Size
Notification size.
Definition: Notifications.h:49
catapult::model::MosaicRequiredNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:412
catapult::model::TransactionDeadlineNotification
Notifies the arrival of a transaction deadline.
Definition: Notifications.h:261
catapult::utils::ByteArray< Address_Decoded_Size, UnresolvedAddress_tag >
catapult::model::TransactionNotification::TransactionType
EntityType TransactionType
Transaction type.
Definition: Notifications.h:254
catapult::model::TransactionFeeNotification::TransactionFeeNotification
TransactionFeeNotification(const Key &signer, uint32_t transactionSize, Amount fee, Amount maxFee)
Creates a transaction fee notification around signer, transactionSize, fee and maxFee.
Definition: Notifications.h:291
catapult::model::MosaicRequiredNotification::Signer
const Key & Signer
Signer.
Definition: Notifications.h:433
catapult::model::TransactionDeadlineNotification::Deadline
Timestamp Deadline
Transaction deadline.
Definition: Notifications.h:276
catapult::model::BasicBalanceNotification::Amount
catapult::Amount Amount
Amount.
Definition: Notifications.h:116
catapult::model::AddressInteractionNotification::AddressInteractionNotification
AddressInteractionNotification(const Key &source, EntityType transactionType, const UnresolvedAddressSet &participantsByAddress, const utils::KeySet &participantsByKey)
Creates a notification around source, transactionType, participantsByAddress and participantsByKey.
Definition: Notifications.h:374
catapult::model::AccountPublicKeyNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:78
catapult::model::TransactionFeeNotification::MaxFee
Amount MaxFee
Definition: Notifications.h:310
catapult::model::SignatureNotification
Notifies the presence of a signature.
Definition: Notifications.h:318
catapult::model::TransactionNotification::TransactionNotification
TransactionNotification(const Key &signer, const Hash256 &transactionHash, EntityType transactionType, Timestamp deadline)
Creates a transaction notification around signer, transactionHash, transactionType and deadline.
Definition: Notifications.h:238
catapult::utils::RawBuffer
BasicRawBuffer< const uint8_t > RawBuffer
A const binary buffer.
Definition: RawBuffer.h:62
catapult::model::SourceChangeNotification::Notification_Type
static constexpr auto Notification_Type
Matching notification type.
Definition: Notifications.h:457
catapult::model::AddressInteractionNotification
Definition: Notifications.h:362