CatapultServer  v0.5.0.1 (Elephant)
catapult::observers Namespace Reference

Classes

class  AggregateNotificationObserverT
 A strongly typed aggregate notification observer. More...
 
class  AggregateObserverBuilder
 A strongly typed aggregate notification observer builder. More...
 
class  DemuxObserverBuilder
 A demultiplexing observer builder. More...
 
class  EntityObserver
 
class  FunctionalNotificationObserverT
 A notification observer implementation that wraps a function. More...
 
class  NotificationObserverAdapter
 A notification observer to entity observer adapter. More...
 
class  NotificationObserverT
 A strongly typed notification observer. More...
 
struct  ObserverContext
 Context passed to all the observers. More...
 
struct  ObserverState
 Block independent mutable state passed to all observers. More...
 
class  ObserverStatementBuilder
 Facade on top of a block statement builder that is accessible by observers. More...
 
class  ReverseNotificationObserverAdapter
 A notification observer to entity observer adapter that reverses the order of raised notifications. More...
 

Typedefs

using Notification = model::TransactionNotification
 
using NotificationObserver = NotificationObserverT< model::Notification >
 A notification observer for processing a generic Notification. More...
 
template<typename TNotification >
using NotificationObserverPointerT = std::unique_ptr< const NotificationObserverT< TNotification > >
 A notification observer (unique) pointer. More...
 
using AggregateNotificationObserver = AggregateNotificationObserverT< model::Notification >
 An aggregate notification observer for processing a generic Notification. More...
 
template<typename TNotification >
using AggregateNotificationObserverPointerT = std::unique_ptr< const AggregateNotificationObserverT< TNotification > >
 An aggregate notification observer (unique) pointer. More...
 

Enumerations

enum  NotifyMode { NotifyMode::NOTIFY_MODE_LIST }
 Enumeration of possible notification modes. More...
 

Functions

 DEFINE_OBSERVER (AccountAddress, model::AccountAddressNotification, [](const auto &notification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.Address);})
 
 DEFINE_OBSERVER (AccountPublicKey, model::AccountPublicKeyNotification, [](const auto &notification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.PublicKey);})
 
 DEFINE_OBSERVER (BalanceDebit, model::BalanceDebitNotification, [](const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::AccountStateCache >();auto senderIter=cache.find(notification.Sender);auto &senderState=senderIter.get();auto mosaicId=context.Resolvers.resolve(notification.MosaicId);if(NotifyMode::Commit==context.Mode) senderState.Balances.debit(mosaicId, notification.Amount);else senderState.Balances.credit(mosaicId, notification.Amount);})
 
 DEFINE_OBSERVER (BalanceTransfer, model::BalanceTransferNotification, [](const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::AccountStateCache >();auto senderIter=cache.find(notification.Sender);auto recipientIter=cache.find(context.Resolvers.resolve(notification.Recipient));auto &senderState=senderIter.get();auto &recipientState=recipientIter.get();auto mosaicId=context.Resolvers.resolve(notification.MosaicId);if(NotifyMode::Commit==context.Mode) Transfer(senderState, recipientState, mosaicId, notification.Amount);else Transfer(recipientState, senderState, mosaicId, notification.Amount);})
 
 DEFINE_OBSERVER (Beneficiary, model::BlockNotification,([](const auto &notification, auto &context) { if(IsOwnBlock(notification.Signer, notification.Beneficiary)) return;UpdateBeneficiaryActivity(notification.Beneficiary, context);}))
 
 DEFINE_OBSERVER (BlockDifficulty, model::BlockNotification, [](const auto &notification, const ObserverContext &context) { auto info=state::BlockDifficultyInfo(context.Height, notification.Timestamp, notification.Difficulty);auto &cache=context.Cache.sub< cache::BlockDifficultyCache >();if(NotifyMode::Commit==context.Mode) cache.insert(info);else cache.remove(info);})
 
 DECLARE_OBSERVER (HarvestFee, Notification)(MosaicId currencyMosaicId
 
return MAKE_OBSERVER (HarvestFee, Notification,([mosaicId, percentage, calculator](const auto &notification, auto &context) { auto inflationAmount=calculator.getSpotAmount(context.Height);auto totalAmount=notification.TotalFee+inflationAmount;auto beneficiaryAmount=ShouldShareFees(notification.Signer, notification.Beneficiary, percentage) ? Amount(totalAmount.unwrap() *percentage/100) :Amount();auto harvesterAmount=totalAmount - beneficiaryAmount;ApplyFee(notification.Signer, { mosaicId, harvesterAmount }, context);if(Amount() !=beneficiaryAmount) ApplyFee(notification.Beneficiary, { mosaicId, beneficiaryAmount }, context);if(Amount() !=inflationAmount &&NotifyMode::Commit==context.Mode) { model::InflationReceipt receipt(model::Receipt_Type_Inflation, mosaicId, inflationAmount);context.StatementBuilder().addReceipt(receipt);} }))
 
 DECLARE_OBSERVER (AccountAddress, model::AccountAddressNotification)()
 Observes account address changes. More...
 
 DECLARE_OBSERVER (AccountPublicKey, model::AccountPublicKeyNotification)()
 Observes account public key changes. More...
 
DECLARE_OBSERVER(RecalculateImportances, model::BlockNotification)(std DECLARE_OBSERVER (HarvestFee, model::BlockNotification)(MosaicId currencyMosaicId
 
 DECLARE_OBSERVER (Beneficiary, model::BlockNotification)()
 Observes block beneficiary. More...
 
 DECLARE_OBSERVER (BlockDifficulty, model::BlockNotification)()
 Observes block difficulties. More...
 
 DECLARE_OBSERVER (TotalTransactions, model::BlockNotification)()
 Observes block notifications and counts transactions. More...
 
 DECLARE_OBSERVER (BalanceTransfer, model::BalanceTransferNotification)()
 Observes balance changes triggered by balance transfer notifications. More...
 
 DECLARE_OBSERVER (BalanceDebit, model::BalanceDebitNotification)()
 Observes balance changes triggered by balance debit notifications. More...
 
 DECLARE_OBSERVER (TransactionFeeActivity, model::TransactionFeeNotification)()
 Observes transaction fee notifications and updates account activity information. More...
 
 DECLARE_OBSERVER (SourceChange, model::SourceChangeNotification)()
 Observes source changes and changes observer source. More...
 
 DECLARE_OBSERVER (RecalculateImportances, model::BlockNotification)(std
 
 DEFINE_OBSERVER (SourceChange, model::SourceChangeNotification, [](const auto &notification, auto &context) { if(NotifyMode::Commit !=context.Mode) return;auto &statementBuilder=context.StatementBuilder();model::ReceiptSource newSource(notification.PrimaryId, notification.SecondaryId);const auto &currentSource=statementBuilder.source();if(model::SourceChangeNotification::SourceChangeType::Relative==notification.PrimaryChangeType) newSource.PrimaryId+=currentSource.PrimaryId;if(model::SourceChangeNotification::SourceChangeType::Relative==notification.SecondaryChangeType) newSource.SecondaryId+=currentSource.SecondaryId;statementBuilder.setSource(newSource);})
 
 DEFINE_OBSERVER (TotalTransactions, model::BlockNotification, [](const auto &notification, const ObserverContext &context) { if(NotifyMode::Commit==context.Mode) context.State.NumTotalTransactions+=notification.NumTransactions;else context.State.NumTotalTransactions -=notification.NumTransactions;})
 
 DEFINE_OBSERVER (TransactionFeeActivity, model::TransactionFeeNotification,([](const auto &notification, auto &context) { auto fee=notification.Fee;if(Amount()==fee) return;importance::UpdateActivity(notification.Signer, context, [fee](auto &bucket) { bucket.TotalFeesPaid=bucket.TotalFeesPaid+fee;}, [fee](auto &bucket) { bucket.TotalFeesPaid=bucket.TotalFeesPaid - fee;});}))
 
 DECLARE_OBSERVER (TransactionHash, model::TransactionNotification)()
 Observes transaction hashes. More...
 
 DEFINE_OBSERVER (TransactionHash, model::TransactionNotification, [](const auto &notification, const ObserverContext &context) { auto timestampedHash=state::TimestampedHash(notification.Deadline, notification.TransactionHash);auto &cache=context.Cache.sub< cache::HashCache >();if(NotifyMode::Commit==context.Mode) cache.insert(timestampedHash);else cache.remove(timestampedHash);})
 
 DEFINE_OBSERVER (AccountLink, model::RemoteAccountLinkNotification, [](const auto &notification, const auto &context) { auto &cache=context.Cache.template sub< cache::AccountStateCache >();auto mainAccountStateIter=cache.find(notification.MainAccountKey);auto &mainAccountState=mainAccountStateIter.get();auto remoteAccountStateIter=cache.find(notification.RemoteAccountKey);auto &remoteAccountState=remoteAccountStateIter.get();if(ShouldLink(notification.LinkAction, context.Mode)) { SetLink(mainAccountState, notification.RemoteAccountKey, state::AccountType::Main);SetLink(remoteAccountState, notification.MainAccountKey, state::AccountType::Remote);} else { SetLink(mainAccountState, Key(), state::AccountType::Unlinked);SetLink(remoteAccountState, Key(), state::AccountType::Remote_Unlinked);} })
 
 DECLARE_OBSERVER (AccountLink, model::RemoteAccountLinkNotification)()
 
 DEFINE_OBSERVER (CompletedAggregate, Notification, [](const auto &notification, auto &context) { if(model::Entity_Type_Aggregate_Bonded !=notification.TransactionType) return;LockStatusAccountBalanceObserver< HashTraits >(notification, context);})
 
 DEFINE_OBSERVER (ExpiredHashLockInfo, model::BlockNotification, [](const auto &notification, auto &context) { ExpiredLockInfoObserver< cache::HashLockInfoCache >(context, [&notification](const auto &) { return notification.Signer;});})
 
 DEFINE_OBSERVER (HashLock, Notification, [](const auto &notification, ObserverContext &context) { auto &cache=context.Cache.sub< cache::HashLockInfoCache >();if(NotifyMode::Commit==context.Mode) { auto endHeight=context.Height+Height(notification.Duration.unwrap());auto mosaicId=context.Resolvers.resolve(notification.Mosaic.MosaicId);cache.insert(CreateLockInfo(notification.Signer, mosaicId, endHeight, notification));auto receiptType=model::Receipt_Type_LockHash_Created;model::BalanceChangeReceipt receipt(receiptType, notification.Signer, mosaicId, notification.Mosaic.Amount);context.StatementBuilder().addReceipt(receipt);} else { cache.remove(notification.Hash);} })
 
 DECLARE_OBSERVER (HashLock, model::HashLockNotification)()
 
 DECLARE_OBSERVER (CompletedAggregate, model::TransactionNotification)()
 
 DECLARE_OBSERVER (ExpiredHashLockInfo, model::BlockNotification)()
 
 DEFINE_OBSERVER (ExpiredSecretLockInfo, model::BlockNotification, [](const auto &, auto &context) { ExpiredLockInfoObserver< cache::SecretLockInfoCache >(context, [](const auto &lockInfo) { return lockInfo.Account;});})
 
 DECLARE_OBSERVER (SecretLock, model::SecretLockNotification)()
 
 DECLARE_OBSERVER (Proof, model::ProofPublicationNotification)()
 
 DECLARE_OBSERVER (ExpiredSecretLockInfo, model::BlockNotification)()
 
 DEFINE_OBSERVER (SecretLock, Notification, [](const auto &notification, ObserverContext &context) { auto &cache=context.Cache.sub< cache::SecretLockInfoCache >();if(NotifyMode::Commit==context.Mode) { auto endHeight=context.Height+Height(notification.Duration.unwrap());auto mosaicId=context.Resolvers.resolve(notification.Mosaic.MosaicId);cache.insert(CreateLockInfo(notification.Signer, mosaicId, endHeight, notification, context.Resolvers));auto receiptType=model::Receipt_Type_LockSecret_Created;model::BalanceChangeReceipt receipt(receiptType, notification.Signer, mosaicId, notification.Mosaic.Amount);context.StatementBuilder().addReceipt(receipt);} else { cache.remove(model::CalculateSecretLockInfoHash(notification.Secret, context.Resolvers.resolve(notification.Recipient)));} })
 
template<typename TLockInfoCache , typename TAccountIdSupplier >
void ExpiredLockInfoObserver (const ObserverContext &context, TAccountIdSupplier ownerAccountIdSupplier)
 
template<typename TTraits >
void LockStatusAccountBalanceObserver (const typename TTraits::Notification &notification, ObserverContext &context)
 
 DEFINE_OBSERVER (MosaicDefinition, model::MosaicDefinitionNotification, [](const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::MosaicCache >();auto mosaicIter=cache.find(notification.MosaicId);if(mosaicIter.tryGet()) { auto mosaicEntry=mosaicIter.get();cache.remove(notification.MosaicId);if(NotifyMode::Rollback==context.Mode &&1==mosaicEntry.definition().revision()) return;cache.insert(ApplyNotification(mosaicEntry, notification, context.Mode));} else { auto definition=state::MosaicDefinition(context.Height, notification.Signer, 1, notification.Properties);cache.insert(state::MosaicEntry(notification.MosaicId, definition));} })
 
 DEFINE_OBSERVER (MosaicSupplyChange, Notification, [](const auto &notification, const ObserverContext &context) { auto mosaicId=context.Resolvers.resolve(notification.MosaicId);auto &accountStateCache=context.Cache.sub< cache::AccountStateCache >();auto &cache=context.Cache.sub< cache::MosaicCache >();auto accountStateIter=accountStateCache.find(notification.Signer);auto &accountState=accountStateIter.get();auto mosaicIter=cache.find(mosaicId);auto &entry=mosaicIter.get();if(ShouldIncrease(context.Mode, notification.Direction)) { accountState.Balances.credit(mosaicId, notification.Delta);entry.increaseSupply(notification.Delta);} else { accountState.Balances.debit(mosaicId, notification.Delta);entry.decreaseSupply(notification.Delta);} })
 
 DECLARE_OBSERVER (MosaicDefinition, model::MosaicDefinitionNotification)()
 
 DECLARE_OBSERVER (MosaicSupplyChange, model::MosaicSupplyChangeNotification)()
 
 DEFINE_OBSERVER (ModifyMultisigCosigners, Notification, [](const auto &notification, const ObserverContext &context) { auto &multisigCache=context.Cache.sub< cache::MultisigCache >();MultisigAccountFacade multisigAccountFacade(multisigCache, notification.Signer);const auto *pModifications=notification.ModificationsPtr;for(auto i=0u;i< notification.ModificationsCount;++i) { auto isNotificationAdd=model::CosignatoryModificationType::Add==pModifications[i].ModificationType;auto isNotificationForward=NotifyMode::Commit==context.Mode;if(isNotificationAdd==isNotificationForward) multisigAccountFacade.addCosignatory(pModifications[i].CosignatoryPublicKey);else multisigAccountFacade.removeCosignatory(pModifications[i].CosignatoryPublicKey);} })
 
 DEFINE_OBSERVER (ModifyMultisigSettings, Notification, [](const Notification &notification, const ObserverContext &context) { auto &multisigCache=context.Cache.sub< cache::MultisigCache >();auto isNotContained=!multisigCache.contains(notification.Signer);if(isNotContained &&observers::NotifyMode::Commit==context.Mode) return;if(isNotContained) multisigCache.insert(state::MultisigEntry(notification.Signer));auto multisigIter=multisigCache.find(notification.Signer);auto &multisigEntry=multisigIter.get();int8_t direction=NotifyMode::Commit==context.Mode ? 1 :-1;multisigEntry.setMinApproval(AddDelta(multisigEntry.minApproval(), direction *notification.MinApprovalDelta));multisigEntry.setMinRemoval(AddDelta(multisigEntry.minRemoval(), direction *notification.MinRemovalDelta));})
 
 DECLARE_OBSERVER (ModifyMultisigCosigners, model::ModifyMultisigCosignersNotification)()
 
 DECLARE_OBSERVER (ModifyMultisigSettings, model::ModifyMultisigSettingsNotification)()
 
 DEFINE_OBSERVER (ChildNamespace, model::ChildNamespaceNotification, [](const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::NamespaceCache >();if(NotifyMode::Rollback==context.Mode) { cache.remove(notification.NamespaceId);return;} auto namespaceIter=cache.find(notification.ParentId);const auto &parentEntry=namespaceIter.get();auto childPath=parentEntry.ns().path();childPath.push_back(notification.NamespaceId);cache.insert(state::Namespace(childPath));})
 
 DECLARE_OBSERVER (AliasedAddress, model::AliasedAddressNotification)()
 
 DECLARE_OBSERVER (AliasedMosaicId, model::AliasedMosaicIdNotification)()
 
 DECLARE_OBSERVER (RootNamespace, model::RootNamespaceNotification)()
 
 DECLARE_OBSERVER (ChildNamespace, model::ChildNamespaceNotification)()
 
 DEFINE_OBSERVER (RootNamespace, model::RootNamespaceNotification, [](const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::NamespaceCache >();if(NotifyMode::Rollback==context.Mode) { cache.remove(notification.NamespaceId);return;} auto lifetimeEnd=Eternal_Artifact_Duration==notification.Duration ? Height(std::numeric_limits< Height::ValueType >::max()) :context.Height+Height(notification.Duration.unwrap());auto lifetime=state::NamespaceLifetime(context.Height, lifetimeEnd);if(cache.contains(notification.NamespaceId)) { auto namespaceIter=cache.find(notification.NamespaceId);const auto &rootEntry=namespaceIter.get();if(IsRenewal(rootEntry.root(), notification, context.Height)) { lifetime=rootEntry.root().lifetime();lifetime.End=lifetime.End+Height(notification.Duration.unwrap());} } auto root=state::RootNamespace(notification.NamespaceId, notification.Signer, lifetime);cache.insert(root);})
 
 DECLARE_OBSERVER (AccountAddressRestrictionValueModification, model::ModifyAccountAddressRestrictionValueNotification)()
 
 DECLARE_OBSERVER (AccountMosaicRestrictionValueModification, model::ModifyAccountMosaicRestrictionValueNotification)()
 
 DECLARE_OBSERVER (AccountOperationRestrictionValueModification, model::ModifyAccountOperationRestrictionValueNotification)()
 
std::ostream & operator<< (std::ostream &out, NotifyMode value)
 Insertion operator for outputting value to out. More...
 
model::ResolverContext Bind (const model::ResolverContext &resolverContext, model::BlockStatementBuilder &statementBuilder)
 Binds resolverContext to statementBuilder. More...
 
constexpr bool ShouldPrune (const ObserverContext &context, size_t pruneInterval)
 Returns true if context and pruneInterval indicate that pruning should be done. More...
 
template<typename TAction >
constexpr bool ShouldLink (TAction action, NotifyMode notifyMode)
 Returns true if action and notifyMode indicate that a link should be made. More...
 
template<typename TCache >
NotificationObserverPointerT< model::BlockNotificationCreateCacheBlockPruningObserver (const std::string &name, size_t interval, BlockDuration gracePeriod)
 
template<typename TCache >
NotificationObserverPointerT< model::BlockNotificationCreateCacheTimePruningObserver (const std::string &name, size_t interval)
 Creates a time-based cache pruning observer with name that runs every interval blocks. More...
 
template<typename TCache >
NotificationObserverPointerT< model::BlockNotificationCreateCacheBlockTouchObserver (const std::string &name, model::ReceiptType receiptType)
 
template<typename TNotification >
NotificationObserverPointerT< TNotification > CreateRentalFeeObserver (const std::string &name, model::ReceiptType receiptType)
 Creates a rental fee observer with name that adds receipts with receiptType. More...
 

Variables

uint8_t harvestBeneficiaryPercentage
 
uint8_t const model::InflationCalculatorcalculator
 
auto percentage = harvestBeneficiaryPercentage
 

Typedef Documentation

◆ AggregateNotificationObserver

An aggregate notification observer for processing a generic Notification.

◆ AggregateNotificationObserverPointerT

template<typename TNotification >
using catapult::observers::AggregateNotificationObserverPointerT = typedef std::unique_ptr<const AggregateNotificationObserverT<TNotification> >

An aggregate notification observer (unique) pointer.

◆ Notification

◆ NotificationObserver

A notification observer for processing a generic Notification.

◆ NotificationObserverPointerT

template<typename TNotification >
using catapult::observers::NotificationObserverPointerT = typedef std::unique_ptr<const NotificationObserverT<TNotification> >

A notification observer (unique) pointer.

Enumeration Type Documentation

◆ NotifyMode

Enumeration of possible notification modes.

Enumerator
NOTIFY_MODE_LIST 

Function Documentation

◆ Bind()

model::ResolverContext catapult::observers::Bind ( const model::ResolverContext resolverContext,
model::BlockStatementBuilder statementBuilder 
)

Binds resolverContext to statementBuilder.

Here is the call graph for this function:

◆ CreateCacheBlockPruningObserver()

template<typename TCache >
NotificationObserverPointerT<model::BlockNotification> catapult::observers::CreateCacheBlockPruningObserver ( const std::string &  name,
size_t  interval,
BlockDuration  gracePeriod 
)

Creates a block-based cache pruning observer with name that runs every interval blocks with the specified grace period (gracePeriod).

Here is the call graph for this function:

◆ CreateCacheBlockTouchObserver()

template<typename TCache >
NotificationObserverPointerT<model::BlockNotification> catapult::observers::CreateCacheBlockTouchObserver ( const std::string &  name,
model::ReceiptType  receiptType 
)

Creates a block-based cache touch observer with name that touches the cache at every block height and creates a receipt of type receiptType for all deactivating elements.

◆ CreateCacheTimePruningObserver()

template<typename TCache >
NotificationObserverPointerT<model::BlockNotification> catapult::observers::CreateCacheTimePruningObserver ( const std::string &  name,
size_t  interval 
)

Creates a time-based cache pruning observer with name that runs every interval blocks.

Here is the call graph for this function:

◆ CreateRentalFeeObserver()

template<typename TNotification >
NotificationObserverPointerT<TNotification> catapult::observers::CreateRentalFeeObserver ( const std::string &  name,
model::ReceiptType  receiptType 
)

Creates a rental fee observer with name that adds receipts with receiptType.

Here is the call graph for this function:

◆ DECLARE_OBSERVER() [1/31]

catapult::observers::DECLARE_OBSERVER ( AccountAddress  ,
model::AccountAddressNotification   
)

Observes account address changes.

◆ DECLARE_OBSERVER() [2/31]

catapult::observers::DECLARE_OBSERVER ( AccountAddressRestrictionValueModification  ,
model::ModifyAccountAddressRestrictionValueNotification   
)

Observes changes triggered by account address restriction value modification notifications and:

  • adds / deletes account address restriction value to / from cache

◆ DECLARE_OBSERVER() [3/31]

catapult::observers::DECLARE_OBSERVER ( AccountLink  ,
model::RemoteAccountLinkNotification   
)

Observes changes triggered by remote account link notifications, including:

  • linking/unlinking remote and main accounts

◆ DECLARE_OBSERVER() [4/31]

catapult::observers::DECLARE_OBSERVER ( AccountMosaicRestrictionValueModification  ,
model::ModifyAccountMosaicRestrictionValueNotification   
)

Observes changes triggered by account mosaic restriction value modification notifications and:

  • adds / deletes account mosaic restriction value to / from cache

◆ DECLARE_OBSERVER() [5/31]

catapult::observers::DECLARE_OBSERVER ( AccountOperationRestrictionValueModification  ,
model::ModifyAccountOperationRestrictionValueNotification   
)

Observes changes triggered by account operation restriction value modification notifications and:

  • adds / deletes account operation restriction value to / from cache

◆ DECLARE_OBSERVER() [6/31]

catapult::observers::DECLARE_OBSERVER ( AccountPublicKey  ,
model::AccountPublicKeyNotification   
)

Observes account public key changes.

◆ DECLARE_OBSERVER() [7/31]

catapult::observers::DECLARE_OBSERVER ( AliasedAddress  ,
model::AliasedAddressNotification   
)

Observes changes triggered by aliased address notifications, including:

  • linking/unlinking address to namespace

◆ DECLARE_OBSERVER() [8/31]

catapult::observers::DECLARE_OBSERVER ( AliasedMosaicId  ,
model::AliasedMosaicIdNotification   
)

Observes changes triggered by aliased mosaic id notifications, including:

  • linking/unlinking mosaic id to namespace

◆ DECLARE_OBSERVER() [9/31]

catapult::observers::DECLARE_OBSERVER ( BalanceDebit  ,
model::BalanceDebitNotification   
)

Observes balance changes triggered by balance debit notifications.

◆ DECLARE_OBSERVER() [10/31]

catapult::observers::DECLARE_OBSERVER ( BalanceTransfer  ,
model::BalanceTransferNotification   
)

Observes balance changes triggered by balance transfer notifications.

◆ DECLARE_OBSERVER() [11/31]

catapult::observers::DECLARE_OBSERVER ( Beneficiary  ,
model::BlockNotification   
)

Observes block beneficiary.

◆ DECLARE_OBSERVER() [12/31]

catapult::observers::DECLARE_OBSERVER ( BlockDifficulty  ,
model::BlockNotification   
)

Observes block difficulties.

◆ DECLARE_OBSERVER() [13/31]

catapult::observers::DECLARE_OBSERVER ( ChildNamespace  ,
model::ChildNamespaceNotification   
)

Observes changes triggered by child namespace notifications, including:

  • creation of namespaces

◆ DECLARE_OBSERVER() [14/31]

catapult::observers::DECLARE_OBSERVER ( CompletedAggregate  ,
model::TransactionNotification   
)

Observes hashes of completed, bonded aggregate transactions and:

  • credits/debits lock owner
  • marks proper hash lock as used/unused

◆ DECLARE_OBSERVER() [15/31]

catapult::observers::DECLARE_OBSERVER ( ExpiredHashLockInfo  ,
model::BlockNotification   
)

Observes block notifications and triggers handling of expired hash lock infos, including:

  • crediting the block signer the mosaics given in the lock info

◆ DECLARE_OBSERVER() [16/31]

catapult::observers::DECLARE_OBSERVER ( ExpiredSecretLockInfo  ,
model::BlockNotification   
)

Observes block notifications and triggers handling of expired secret lock infos, including:

  • crediting the lock creator the mosaics given in the lock info

◆ DECLARE_OBSERVER() [17/31]

DECLARE_OBSERVER (RecalculateImportances, model::BlockNotification)( std catapult::observers::DECLARE_OBSERVER ( HarvestFee  ,
model::BlockNotification   
)

Observes block notifications and triggers importance recalculations using either pCommitCalculator (for commits) or pRollbackCalculator (for rollbacks). Observes block notifications and credits the harvester and optionally the beneficiary account with transaction fees given the currency mosaic id (currencyMosaicId), the harvest beneficiary percentage (harvestBeneficiaryPercentage) and the inflation calculator.

◆ DECLARE_OBSERVER() [18/31]

catapult::observers::DECLARE_OBSERVER ( HarvestFee  ,
Notification   
)

◆ DECLARE_OBSERVER() [19/31]

catapult::observers::DECLARE_OBSERVER ( HashLock  ,
model::HashLockNotification   
)

Observes changes triggered by hash lock notifications and:

  • adds/removes hash lock info to/from hash lock info cache

◆ DECLARE_OBSERVER() [20/31]

catapult::observers::DECLARE_OBSERVER ( ModifyMultisigCosigners  ,
model::ModifyMultisigCosignersNotification   
)

Observes changes triggered by modify multisig cosigners notifications and:

  • adds / deletes multisig account to / from cache
  • adds / deletes cosignatories

◆ DECLARE_OBSERVER() [21/31]

catapult::observers::DECLARE_OBSERVER ( ModifyMultisigSettings  ,
model::ModifyMultisigSettingsNotification   
)

Observes changes triggered by modify multisig settings notifications and:

  • sets new values of min removal and min approval

◆ DECLARE_OBSERVER() [22/31]

catapult::observers::DECLARE_OBSERVER ( MosaicDefinition  ,
model::MosaicDefinitionNotification   
)

Observes changes triggered by mosaic definition notifications, including:

  • creation of mosaics

◆ DECLARE_OBSERVER() [23/31]

catapult::observers::DECLARE_OBSERVER ( MosaicSupplyChange  ,
model::MosaicSupplyChangeNotification   
)

Observes changes triggered by mosaic supply change notifications, including:

  • increase or decrease of supply

◆ DECLARE_OBSERVER() [24/31]

catapult::observers::DECLARE_OBSERVER ( Proof  ,
model::ProofPublicationNotification   
)

Observes changes triggered by proof notifications and:

  • credits/debits proof publisher
  • marks proper secret lock as used/unused

◆ DECLARE_OBSERVER() [25/31]

catapult::observers::DECLARE_OBSERVER ( RecalculateImportances  ,
model::BlockNotification   
)

◆ DECLARE_OBSERVER() [26/31]

catapult::observers::DECLARE_OBSERVER ( RootNamespace  ,
model::RootNamespaceNotification   
)

Observes changes triggered by root namespace notifications, including:

  • creation of namespaces

◆ DECLARE_OBSERVER() [27/31]

catapult::observers::DECLARE_OBSERVER ( SecretLock  ,
model::SecretLockNotification   
)

Observes changes triggered by secret lock notifications and:

  • adds/removes secret lock info to/from secret lock info cache
  • debits/credits lock owner

◆ DECLARE_OBSERVER() [28/31]

catapult::observers::DECLARE_OBSERVER ( SourceChange  ,
model::SourceChangeNotification   
)

Observes source changes and changes observer source.

◆ DECLARE_OBSERVER() [29/31]

catapult::observers::DECLARE_OBSERVER ( TotalTransactions  ,
model::BlockNotification   
)

Observes block notifications and counts transactions.

◆ DECLARE_OBSERVER() [30/31]

catapult::observers::DECLARE_OBSERVER ( TransactionFeeActivity  ,
model::TransactionFeeNotification   
)

Observes transaction fee notifications and updates account activity information.

◆ DECLARE_OBSERVER() [31/31]

catapult::observers::DECLARE_OBSERVER ( TransactionHash  ,
model::TransactionNotification   
)

Observes transaction hashes.

◆ DEFINE_OBSERVER() [1/22]

catapult::observers::DEFINE_OBSERVER ( AccountAddress  ,
model::AccountAddressNotification  ,
[] (const auto &notification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.Address);}   
)

◆ DEFINE_OBSERVER() [2/22]

catapult::observers::DEFINE_OBSERVER ( AccountLink  ,
model::RemoteAccountLinkNotification  ,
[] (const auto &notification, const auto &context) { auto &cache=context.Cache.template sub< cache::AccountStateCache >();auto mainAccountStateIter=cache.find(notification.MainAccountKey);auto &mainAccountState=mainAccountStateIter.get();auto remoteAccountStateIter=cache.find(notification.RemoteAccountKey);auto &remoteAccountState=remoteAccountStateIter.get();if(ShouldLink(notification.LinkAction, context.Mode)) { SetLink(mainAccountState, notification.RemoteAccountKey, state::AccountType::Main);SetLink(remoteAccountState, notification.MainAccountKey, state::AccountType::Remote);} else { SetLink(mainAccountState, Key(), state::AccountType::Unlinked);SetLink(remoteAccountState, Key(), state::AccountType::Remote_Unlinked);} }   
)

◆ DEFINE_OBSERVER() [3/22]

catapult::observers::DEFINE_OBSERVER ( AccountPublicKey  ,
model::AccountPublicKeyNotification  ,
[] (const auto &notification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.PublicKey);}   
)

◆ DEFINE_OBSERVER() [4/22]

catapult::observers::DEFINE_OBSERVER ( BalanceDebit  ,
model::BalanceDebitNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::AccountStateCache >();auto senderIter=cache.find(notification.Sender);auto &senderState=senderIter.get();auto mosaicId=context.Resolvers.resolve(notification.MosaicId);if(NotifyMode::Commit==context.Mode) senderState.Balances.debit(mosaicId, notification.Amount);else senderState.Balances.credit(mosaicId, notification.Amount);}   
)

◆ DEFINE_OBSERVER() [5/22]

catapult::observers::DEFINE_OBSERVER ( BalanceTransfer  ,
model::BalanceTransferNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::AccountStateCache >();auto senderIter=cache.find(notification.Sender);auto recipientIter=cache.find(context.Resolvers.resolve(notification.Recipient));auto &senderState=senderIter.get();auto &recipientState=recipientIter.get();auto mosaicId=context.Resolvers.resolve(notification.MosaicId);if(NotifyMode::Commit==context.Mode) Transfer(senderState, recipientState, mosaicId, notification.Amount);else Transfer(recipientState, senderState, mosaicId, notification.Amount);}   
)

◆ DEFINE_OBSERVER() [6/22]

catapult::observers::DEFINE_OBSERVER ( Beneficiary  ,
model::BlockNotification  ,
([](const auto &notification, auto &context) { if(IsOwnBlock(notification.Signer, notification.Beneficiary)) return;UpdateBeneficiaryActivity(notification.Beneficiary, context);})   
)

◆ DEFINE_OBSERVER() [7/22]

catapult::observers::DEFINE_OBSERVER ( BlockDifficulty  ,
model::BlockNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto info=state::BlockDifficultyInfo(context.Height, notification.Timestamp, notification.Difficulty);auto &cache=context.Cache.sub< cache::BlockDifficultyCache >();if(NotifyMode::Commit==context.Mode) cache.insert(info);else cache.remove(info);}   
)

◆ DEFINE_OBSERVER() [8/22]

catapult::observers::DEFINE_OBSERVER ( ChildNamespace  ,
model::ChildNamespaceNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::NamespaceCache >();if(NotifyMode::Rollback==context.Mode) { cache.remove(notification.NamespaceId);return;} auto namespaceIter=cache.find(notification.ParentId);const auto &parentEntry=namespaceIter.get();auto childPath=parentEntry.ns().path();childPath.push_back(notification.NamespaceId);cache.insert(state::Namespace(childPath));}   
)

◆ DEFINE_OBSERVER() [9/22]

catapult::observers::DEFINE_OBSERVER ( CompletedAggregate  ,
Notification  ,
[] (const auto &notification, auto &context) { if(model::Entity_Type_Aggregate_Bonded !=notification.TransactionType) return;LockStatusAccountBalanceObserver< HashTraits >(notification, context);}   
)

◆ DEFINE_OBSERVER() [10/22]

catapult::observers::DEFINE_OBSERVER ( ExpiredHashLockInfo  ,
model::BlockNotification  ,
[] (const auto &notification, auto &context) { ExpiredLockInfoObserver< cache::HashLockInfoCache >(context, [&notification](const auto &) { return notification.Signer;});}   
)

◆ DEFINE_OBSERVER() [11/22]

catapult::observers::DEFINE_OBSERVER ( ExpiredSecretLockInfo  ,
model::BlockNotification  ,
[] (const auto &, auto &context) { ExpiredLockInfoObserver< cache::SecretLockInfoCache >(context, [](const auto &lockInfo) { return lockInfo.Account;});}   
)

◆ DEFINE_OBSERVER() [12/22]

catapult::observers::DEFINE_OBSERVER ( HashLock  ,
Notification  ,
[] (const auto &notification, ObserverContext &context) { auto &cache=context.Cache.sub< cache::HashLockInfoCache >();if(NotifyMode::Commit==context.Mode) { auto endHeight=context.Height+Height(notification.Duration.unwrap());auto mosaicId=context.Resolvers.resolve(notification.Mosaic.MosaicId);cache.insert(CreateLockInfo(notification.Signer, mosaicId, endHeight, notification));auto receiptType=model::Receipt_Type_LockHash_Created;model::BalanceChangeReceipt receipt(receiptType, notification.Signer, mosaicId, notification.Mosaic.Amount);context.StatementBuilder().addReceipt(receipt);} else { cache.remove(notification.Hash);} }   
)

◆ DEFINE_OBSERVER() [13/22]

catapult::observers::DEFINE_OBSERVER ( ModifyMultisigCosigners  ,
Notification  ,
[] (const auto &notification, const ObserverContext &context) { auto &multisigCache=context.Cache.sub< cache::MultisigCache >();MultisigAccountFacade multisigAccountFacade(multisigCache, notification.Signer);const auto *pModifications=notification.ModificationsPtr;for(auto i=0u;i< notification.ModificationsCount;++i) { auto isNotificationAdd=model::CosignatoryModificationType::Add==pModifications[i].ModificationType;auto isNotificationForward=NotifyMode::Commit==context.Mode;if(isNotificationAdd==isNotificationForward) multisigAccountFacade.addCosignatory(pModifications[i].CosignatoryPublicKey);else multisigAccountFacade.removeCosignatory(pModifications[i].CosignatoryPublicKey);} }   
)

◆ DEFINE_OBSERVER() [14/22]

catapult::observers::DEFINE_OBSERVER ( ModifyMultisigSettings  ,
Notification  ,
[] (const Notification &notification, const ObserverContext &context) { auto &multisigCache=context.Cache.sub< cache::MultisigCache >();auto isNotContained=!multisigCache.contains(notification.Signer);if(isNotContained &&observers::NotifyMode::Commit==context.Mode) return;if(isNotContained) multisigCache.insert(state::MultisigEntry(notification.Signer));auto multisigIter=multisigCache.find(notification.Signer);auto &multisigEntry=multisigIter.get();int8_t direction=NotifyMode::Commit==context.Mode ? 1 :-1;multisigEntry.setMinApproval(AddDelta(multisigEntry.minApproval(), direction *notification.MinApprovalDelta));multisigEntry.setMinRemoval(AddDelta(multisigEntry.minRemoval(), direction *notification.MinRemovalDelta));}   
)

◆ DEFINE_OBSERVER() [15/22]

catapult::observers::DEFINE_OBSERVER ( MosaicDefinition  ,
model::MosaicDefinitionNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::MosaicCache >();auto mosaicIter=cache.find(notification.MosaicId);if(mosaicIter.tryGet()) { auto mosaicEntry=mosaicIter.get();cache.remove(notification.MosaicId);if(NotifyMode::Rollback==context.Mode &&1==mosaicEntry.definition().revision()) return;cache.insert(ApplyNotification(mosaicEntry, notification, context.Mode));} else { auto definition=state::MosaicDefinition(context.Height, notification.Signer, 1, notification.Properties);cache.insert(state::MosaicEntry(notification.MosaicId, definition));} }   
)

◆ DEFINE_OBSERVER() [16/22]

catapult::observers::DEFINE_OBSERVER ( MosaicSupplyChange  ,
Notification  ,
[] (const auto &notification, const ObserverContext &context) { auto mosaicId=context.Resolvers.resolve(notification.MosaicId);auto &accountStateCache=context.Cache.sub< cache::AccountStateCache >();auto &cache=context.Cache.sub< cache::MosaicCache >();auto accountStateIter=accountStateCache.find(notification.Signer);auto &accountState=accountStateIter.get();auto mosaicIter=cache.find(mosaicId);auto &entry=mosaicIter.get();if(ShouldIncrease(context.Mode, notification.Direction)) { accountState.Balances.credit(mosaicId, notification.Delta);entry.increaseSupply(notification.Delta);} else { accountState.Balances.debit(mosaicId, notification.Delta);entry.decreaseSupply(notification.Delta);} }   
)

◆ DEFINE_OBSERVER() [17/22]

catapult::observers::DEFINE_OBSERVER ( RootNamespace  ,
model::RootNamespaceNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto &cache=context.Cache.sub< cache::NamespaceCache >();if(NotifyMode::Rollback==context.Mode) { cache.remove(notification.NamespaceId);return;} auto lifetimeEnd=Eternal_Artifact_Duration==notification.Duration ? Height(std::numeric_limits< Height::ValueType >::max()) :context.Height+Height(notification.Duration.unwrap());auto lifetime=state::NamespaceLifetime(context.Height, lifetimeEnd);if(cache.contains(notification.NamespaceId)) { auto namespaceIter=cache.find(notification.NamespaceId);const auto &rootEntry=namespaceIter.get();if(IsRenewal(rootEntry.root(), notification, context.Height)) { lifetime=rootEntry.root().lifetime();lifetime.End=lifetime.End+Height(notification.Duration.unwrap());} } auto root=state::RootNamespace(notification.NamespaceId, notification.Signer, lifetime);cache.insert(root);}   
)

◆ DEFINE_OBSERVER() [18/22]

catapult::observers::DEFINE_OBSERVER ( SecretLock  ,
Notification  ,
[] (const auto &notification, ObserverContext &context) { auto &cache=context.Cache.sub< cache::SecretLockInfoCache >();if(NotifyMode::Commit==context.Mode) { auto endHeight=context.Height+Height(notification.Duration.unwrap());auto mosaicId=context.Resolvers.resolve(notification.Mosaic.MosaicId);cache.insert(CreateLockInfo(notification.Signer, mosaicId, endHeight, notification, context.Resolvers));auto receiptType=model::Receipt_Type_LockSecret_Created;model::BalanceChangeReceipt receipt(receiptType, notification.Signer, mosaicId, notification.Mosaic.Amount);context.StatementBuilder().addReceipt(receipt);} else { cache.remove(model::CalculateSecretLockInfoHash(notification.Secret, context.Resolvers.resolve(notification.Recipient)));} }   
)

◆ DEFINE_OBSERVER() [19/22]

catapult::observers::DEFINE_OBSERVER ( SourceChange  ,
model::SourceChangeNotification  ,
[] (const auto &notification, auto &context) { if(NotifyMode::Commit !=context.Mode) return;auto &statementBuilder=context.StatementBuilder();model::ReceiptSource newSource(notification.PrimaryId, notification.SecondaryId);const auto &currentSource=statementBuilder.source();if(model::SourceChangeNotification::SourceChangeType::Relative==notification.PrimaryChangeType) newSource.PrimaryId+=currentSource.PrimaryId;if(model::SourceChangeNotification::SourceChangeType::Relative==notification.SecondaryChangeType) newSource.SecondaryId+=currentSource.SecondaryId;statementBuilder.setSource(newSource);}   
)

◆ DEFINE_OBSERVER() [20/22]

catapult::observers::DEFINE_OBSERVER ( TotalTransactions  ,
model::BlockNotification  ,
[] (const auto &notification, const ObserverContext &context) { if(NotifyMode::Commit==context.Mode) context.State.NumTotalTransactions+=notification.NumTransactions;else context.State.NumTotalTransactions -=notification.NumTransactions;}   
)

◆ DEFINE_OBSERVER() [21/22]

catapult::observers::DEFINE_OBSERVER ( TransactionFeeActivity  ,
model::TransactionFeeNotification  ,
([](const auto &notification, auto &context) { auto fee=notification.Fee;if(Amount()==fee) return;importance::UpdateActivity(notification.Signer, context,[fee](auto &bucket) { bucket.TotalFeesPaid=bucket.TotalFeesPaid+fee;},[fee](auto &bucket) { bucket.TotalFeesPaid=bucket.TotalFeesPaid - fee;});})   
)

◆ DEFINE_OBSERVER() [22/22]

catapult::observers::DEFINE_OBSERVER ( TransactionHash  ,
model::TransactionNotification  ,
[] (const auto &notification, const ObserverContext &context) { auto timestampedHash=state::TimestampedHash(notification.Deadline, notification.TransactionHash);auto &cache=context.Cache.sub< cache::HashCache >();if(NotifyMode::Commit==context.Mode) cache.insert(timestampedHash);else cache.remove(timestampedHash);}   
)

◆ ExpiredLockInfoObserver()

template<typename TLockInfoCache , typename TAccountIdSupplier >
void catapult::observers::ExpiredLockInfoObserver ( const ObserverContext context,
TAccountIdSupplier  ownerAccountIdSupplier 
)

On commit, credits the expiration account of expired locks. On rollback, debits the expiration account of expired locks. Uses the observer context to determine notification direction and access caches. Uses ownerAccountIdSupplier to retrieve the lock owner's account identifier.

Here is the call graph for this function:

◆ LockStatusAccountBalanceObserver()

template<typename TTraits >
void catapult::observers::LockStatusAccountBalanceObserver ( const typename TTraits::Notification &  notification,
ObserverContext context 
)

On commit, marks lock as used and credits destination account. On rollback, marks lock as unused and debits destination account. Uses the observer context to determine notification direction and access caches. Uses notification to determine the destination account.

Here is the call graph for this function:

◆ MAKE_OBSERVER()

return catapult::observers::MAKE_OBSERVER ( HarvestFee  ,
Notification  ,
([mosaicId, percentage, calculator](const auto &notification, auto &context) { auto inflationAmount=calculator.getSpotAmount(context.Height);auto totalAmount=notification.TotalFee+inflationAmount;auto beneficiaryAmount=ShouldShareFees(notification.Signer, notification.Beneficiary, percentage) ? Amount(totalAmount.unwrap() *percentage/100) :Amount();auto harvesterAmount=totalAmount - beneficiaryAmount;ApplyFee(notification.Signer, { mosaicId, harvesterAmount }, context);if(Amount() !=beneficiaryAmount) ApplyFee(notification.Beneficiary, { mosaicId, beneficiaryAmount }, context);if(Amount() !=inflationAmount &&NotifyMode::Commit==context.Mode) { model::InflationReceipt receipt(model::Receipt_Type_Inflation, mosaicId, inflationAmount);context.StatementBuilder().addReceipt(receipt);} })   
)

◆ operator<<()

std::ostream& catapult::observers::operator<< ( std::ostream &  out,
NotifyMode  value 
)

Insertion operator for outputting value to out.

◆ ShouldLink()

template<typename TAction >
constexpr bool catapult::observers::ShouldLink ( TAction  action,
NotifyMode  notifyMode 
)
constexpr

Returns true if action and notifyMode indicate that a link should be made.

◆ ShouldPrune()

constexpr bool catapult::observers::ShouldPrune ( const ObserverContext context,
size_t  pruneInterval 
)
constexpr

Returns true if context and pruneInterval indicate that pruning should be done.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ calculator

DECLARE_OBSERVER (RecalculateImportances, model::BlockNotification)( std uint8_t const model::InflationCalculator& catapult::observers::calculator
Initial value:
{
auto mosaicId = currencyMosaicId

◆ harvestBeneficiaryPercentage

DECLARE_OBSERVER (RecalculateImportances, model::BlockNotification)( std uint8_t catapult::observers::harvestBeneficiaryPercentage

◆ percentage

auto catapult::observers::percentage = harvestBeneficiaryPercentage