CatapultServer
v0.5.0.1 (Elephant)
|
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 ¬ification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.Address);}) | |
DEFINE_OBSERVER (AccountPublicKey, model::AccountPublicKeyNotification, [](const auto ¬ification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.PublicKey);}) | |
DEFINE_OBSERVER (BalanceDebit, model::BalanceDebitNotification, [](const auto ¬ification, 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 ¬ification, 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 ¬ification, auto &context) { if(IsOwnBlock(notification.Signer, notification.Beneficiary)) return;UpdateBeneficiaryActivity(notification.Beneficiary, context);})) | |
DEFINE_OBSERVER (BlockDifficulty, model::BlockNotification, [](const auto ¬ification, 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 ¬ification, 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 ¬ification, auto &context) { if(NotifyMode::Commit !=context.Mode) return;auto &statementBuilder=context.StatementBuilder();model::ReceiptSource newSource(notification.PrimaryId, notification.SecondaryId);const auto ¤tSource=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 ¬ification, 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 ¬ification, 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 ¬ification, 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 ¬ification, 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 ¬ification, auto &context) { if(model::Entity_Type_Aggregate_Bonded !=notification.TransactionType) return;LockStatusAccountBalanceObserver< HashTraits >(notification, context);}) | |
DEFINE_OBSERVER (ExpiredHashLockInfo, model::BlockNotification, [](const auto ¬ification, auto &context) { ExpiredLockInfoObserver< cache::HashLockInfoCache >(context, [¬ification](const auto &) { return notification.Signer;});}) | |
DEFINE_OBSERVER (HashLock, Notification, [](const auto ¬ification, 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 ¬ification, 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 ¬ification, ObserverContext &context) |
DEFINE_OBSERVER (MosaicDefinition, model::MosaicDefinitionNotification, [](const auto ¬ification, 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 ¬ification, 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 ¬ification, 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 ¬ification, 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 ¬ification, 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 ¬ification, 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::BlockNotification > | CreateCacheBlockPruningObserver (const std::string &name, size_t interval, BlockDuration gracePeriod) |
template<typename TCache > | |
NotificationObserverPointerT< model::BlockNotification > | CreateCacheTimePruningObserver (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::BlockNotification > | CreateCacheBlockTouchObserver (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::InflationCalculator & | calculator |
auto | percentage = harvestBeneficiaryPercentage |
using catapult::observers::AggregateNotificationObserver = typedef AggregateNotificationObserverT<model::Notification> |
An aggregate notification observer for processing a generic Notification.
using catapult::observers::AggregateNotificationObserverPointerT = typedef std::unique_ptr<const AggregateNotificationObserverT<TNotification> > |
An aggregate notification observer (unique) pointer.
using catapult::observers::NotificationObserver = typedef NotificationObserverT<model::Notification> |
A notification observer for processing a generic Notification.
using catapult::observers::NotificationObserverPointerT = typedef std::unique_ptr<const NotificationObserverT<TNotification> > |
A notification observer (unique) pointer.
|
strong |
model::ResolverContext catapult::observers::Bind | ( | const model::ResolverContext & | resolverContext, |
model::BlockStatementBuilder & | statementBuilder | ||
) |
Binds resolverContext to statementBuilder.
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).
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.
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.
NotificationObserverPointerT<TNotification> catapult::observers::CreateRentalFeeObserver | ( | const std::string & | name, |
model::ReceiptType | receiptType | ||
) |
Creates a rental fee observer with name that adds receipts with receiptType.
catapult::observers::DECLARE_OBSERVER | ( | AccountAddress | , |
model::AccountAddressNotification | |||
) |
Observes account address changes.
catapult::observers::DECLARE_OBSERVER | ( | AccountAddressRestrictionValueModification | , |
model::ModifyAccountAddressRestrictionValueNotification | |||
) |
Observes changes triggered by account address restriction value modification notifications and:
catapult::observers::DECLARE_OBSERVER | ( | AccountLink | , |
model::RemoteAccountLinkNotification | |||
) |
Observes changes triggered by remote account link notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | AccountMosaicRestrictionValueModification | , |
model::ModifyAccountMosaicRestrictionValueNotification | |||
) |
Observes changes triggered by account mosaic restriction value modification notifications and:
catapult::observers::DECLARE_OBSERVER | ( | AccountOperationRestrictionValueModification | , |
model::ModifyAccountOperationRestrictionValueNotification | |||
) |
Observes changes triggered by account operation restriction value modification notifications and:
catapult::observers::DECLARE_OBSERVER | ( | AccountPublicKey | , |
model::AccountPublicKeyNotification | |||
) |
Observes account public key changes.
catapult::observers::DECLARE_OBSERVER | ( | AliasedAddress | , |
model::AliasedAddressNotification | |||
) |
Observes changes triggered by aliased address notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | AliasedMosaicId | , |
model::AliasedMosaicIdNotification | |||
) |
Observes changes triggered by aliased mosaic id notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | BalanceDebit | , |
model::BalanceDebitNotification | |||
) |
Observes balance changes triggered by balance debit notifications.
catapult::observers::DECLARE_OBSERVER | ( | BalanceTransfer | , |
model::BalanceTransferNotification | |||
) |
Observes balance changes triggered by balance transfer notifications.
catapult::observers::DECLARE_OBSERVER | ( | Beneficiary | , |
model::BlockNotification | |||
) |
Observes block beneficiary.
catapult::observers::DECLARE_OBSERVER | ( | BlockDifficulty | , |
model::BlockNotification | |||
) |
Observes block difficulties.
catapult::observers::DECLARE_OBSERVER | ( | ChildNamespace | , |
model::ChildNamespaceNotification | |||
) |
Observes changes triggered by child namespace notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | CompletedAggregate | , |
model::TransactionNotification | |||
) |
Observes hashes of completed, bonded aggregate transactions and:
catapult::observers::DECLARE_OBSERVER | ( | ExpiredHashLockInfo | , |
model::BlockNotification | |||
) |
Observes block notifications and triggers handling of expired hash lock infos, including:
catapult::observers::DECLARE_OBSERVER | ( | ExpiredSecretLockInfo | , |
model::BlockNotification | |||
) |
Observes block notifications and triggers handling of expired secret lock infos, including:
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.
catapult::observers::DECLARE_OBSERVER | ( | HarvestFee | , |
Notification | |||
) |
catapult::observers::DECLARE_OBSERVER | ( | HashLock | , |
model::HashLockNotification | |||
) |
Observes changes triggered by hash lock notifications and:
catapult::observers::DECLARE_OBSERVER | ( | ModifyMultisigCosigners | , |
model::ModifyMultisigCosignersNotification | |||
) |
Observes changes triggered by modify multisig cosigners notifications and:
catapult::observers::DECLARE_OBSERVER | ( | ModifyMultisigSettings | , |
model::ModifyMultisigSettingsNotification | |||
) |
Observes changes triggered by modify multisig settings notifications and:
catapult::observers::DECLARE_OBSERVER | ( | MosaicDefinition | , |
model::MosaicDefinitionNotification | |||
) |
Observes changes triggered by mosaic definition notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | MosaicSupplyChange | , |
model::MosaicSupplyChangeNotification | |||
) |
Observes changes triggered by mosaic supply change notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | Proof | , |
model::ProofPublicationNotification | |||
) |
Observes changes triggered by proof notifications and:
catapult::observers::DECLARE_OBSERVER | ( | RecalculateImportances | , |
model::BlockNotification | |||
) |
catapult::observers::DECLARE_OBSERVER | ( | RootNamespace | , |
model::RootNamespaceNotification | |||
) |
Observes changes triggered by root namespace notifications, including:
catapult::observers::DECLARE_OBSERVER | ( | SecretLock | , |
model::SecretLockNotification | |||
) |
Observes changes triggered by secret lock notifications and:
catapult::observers::DECLARE_OBSERVER | ( | SourceChange | , |
model::SourceChangeNotification | |||
) |
Observes source changes and changes observer source.
catapult::observers::DECLARE_OBSERVER | ( | TotalTransactions | , |
model::BlockNotification | |||
) |
Observes block notifications and counts transactions.
catapult::observers::DECLARE_OBSERVER | ( | TransactionFeeActivity | , |
model::TransactionFeeNotification | |||
) |
Observes transaction fee notifications and updates account activity information.
catapult::observers::DECLARE_OBSERVER | ( | TransactionHash | , |
model::TransactionNotification | |||
) |
Observes transaction hashes.
catapult::observers::DEFINE_OBSERVER | ( | AccountAddress | , |
model::AccountAddressNotification | , | ||
[] (const auto ¬ification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.Address);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | AccountLink | , |
model::RemoteAccountLinkNotification | , | ||
[] (const auto ¬ification, 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);} } | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | AccountPublicKey | , |
model::AccountPublicKeyNotification | , | ||
[] (const auto ¬ification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.PublicKey);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | BalanceDebit | , |
model::BalanceDebitNotification | , | ||
[] (const auto ¬ification, 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);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | BalanceTransfer | , |
model::BalanceTransferNotification | , | ||
[] (const auto ¬ification, 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);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | Beneficiary | , |
model::BlockNotification | , | ||
([](const auto ¬ification, auto &context) { if(IsOwnBlock(notification.Signer, notification.Beneficiary)) return;UpdateBeneficiaryActivity(notification.Beneficiary, context);}) | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | BlockDifficulty | , |
model::BlockNotification | , | ||
[] (const auto ¬ification, 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);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | ChildNamespace | , |
model::ChildNamespaceNotification | , | ||
[] (const auto ¬ification, 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));} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | CompletedAggregate | , |
Notification | , | ||
[] (const auto ¬ification, auto &context) { if(model::Entity_Type_Aggregate_Bonded !=notification.TransactionType) return;LockStatusAccountBalanceObserver< HashTraits >(notification, context);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | ExpiredHashLockInfo | , |
model::BlockNotification | , | ||
[] (const auto ¬ification, auto &context) { ExpiredLockInfoObserver< cache::HashLockInfoCache >(context, [¬ification](const auto &) { return notification.Signer;});} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | ExpiredSecretLockInfo | , |
model::BlockNotification | , | ||
[] (const auto &, auto &context) { ExpiredLockInfoObserver< cache::SecretLockInfoCache >(context, [](const auto &lockInfo) { return lockInfo.Account;});} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | HashLock | , |
Notification | , | ||
[] (const auto ¬ification, 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);} } | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | ModifyMultisigCosigners | , |
Notification | , | ||
[] (const auto ¬ification, 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);} } | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | ModifyMultisigSettings | , |
Notification | , | ||
[] (const Notification ¬ification, 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));} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | MosaicDefinition | , |
model::MosaicDefinitionNotification | , | ||
[] (const auto ¬ification, 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));} } | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | MosaicSupplyChange | , |
Notification | , | ||
[] (const auto ¬ification, 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);} } | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | RootNamespace | , |
model::RootNamespaceNotification | , | ||
[] (const auto ¬ification, 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);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | SecretLock | , |
Notification | , | ||
[] (const auto ¬ification, 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)));} } | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | SourceChange | , |
model::SourceChangeNotification | , | ||
[] (const auto ¬ification, auto &context) { if(NotifyMode::Commit !=context.Mode) return;auto &statementBuilder=context.StatementBuilder();model::ReceiptSource newSource(notification.PrimaryId, notification.SecondaryId);const auto ¤tSource=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);} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | TotalTransactions | , |
model::BlockNotification | , | ||
[] (const auto ¬ification, const ObserverContext &context) { if(NotifyMode::Commit==context.Mode) context.State.NumTotalTransactions+=notification.NumTransactions;else context.State.NumTotalTransactions -=notification.NumTransactions;} | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | TransactionFeeActivity | , |
model::TransactionFeeNotification | , | ||
([](const auto ¬ification, 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;});}) | |||
) |
catapult::observers::DEFINE_OBSERVER | ( | TransactionHash | , |
model::TransactionNotification | , | ||
[] (const auto ¬ification, 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);} | |||
) |
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.
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.
return catapult::observers::MAKE_OBSERVER | ( | HarvestFee | , |
Notification | , | ||
([mosaicId, percentage, calculator](const auto ¬ification, 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);} }) | |||
) |
std::ostream& catapult::observers::operator<< | ( | std::ostream & | out, |
NotifyMode | value | ||
) |
Insertion operator for outputting value to out.
|
constexpr |
Returns true
if action and notifyMode indicate that a link should be made.
|
constexpr |
Returns true
if context and pruneInterval indicate that pruning should be done.
DECLARE_OBSERVER (RecalculateImportances, model::BlockNotification)( std uint8_t const model::InflationCalculator& catapult::observers::calculator |
DECLARE_OBSERVER (RecalculateImportances, model::BlockNotification)( std uint8_t catapult::observers::harvestBeneficiaryPercentage |
auto catapult::observers::percentage = harvestBeneficiaryPercentage |