CatapultServer  v0.5.0.1 (Elephant)
ExpiredLockInfoObserver.h
Go to the documentation of this file.
1 
21 #pragma once
23 
24 namespace catapult { namespace observers {
25 
30  template<typename TLockInfoCache, typename TAccountIdSupplier>
31  void ExpiredLockInfoObserver(const ObserverContext& context, TAccountIdSupplier ownerAccountIdSupplier) {
32  auto& accountStateCache = context.Cache.sub<cache::AccountStateCache>();
33  auto& lockInfoCache = context.Cache.template sub<TLockInfoCache>();
34 
35  lockInfoCache.processUnusedExpiredLocks(context.Height, [&context, &accountStateCache, ownerAccountIdSupplier](
36  const auto& lockInfo) {
37  auto accountStateIter = accountStateCache.find(ownerAccountIdSupplier(lockInfo));
38  auto& accountState = accountStateIter.get();
39  if (NotifyMode::Commit == context.Mode)
40  accountState.Balances.credit(lockInfo.MosaicId, lockInfo.Amount);
41  else
42  accountState.Balances.debit(lockInfo.MosaicId, lockInfo.Amount);
43  });
44  }
45 }}
catapult::observers::ObserverContext::Cache
cache::CatapultCacheDelta & Cache
Catapult cache.
Definition: ObserverContext.h:86
catapult::observers::ExpiredLockInfoObserver
void ExpiredLockInfoObserver(const ObserverContext &context, TAccountIdSupplier ownerAccountIdSupplier)
Definition: ExpiredLockInfoObserver.h:31
catapult::observers::ObserverContext
Context passed to all the observers.
Definition: ObserverContext.h:78
catapult::cache::CatapultCacheDelta::sub
const TCache::CacheDeltaType & sub() const
Gets a specific sub cache delta view.
Definition: CatapultCacheDelta.h:47
catapult::observers::DEFINE_OBSERVER
DEFINE_OBSERVER(AccountAddress, model::AccountAddressNotification, [](const auto &notification, const auto &context) { DefaultAccountVisitor visitor(context);visitor.visit(notification.Address);})
ObserverUtils.h
HashLockInfoCache.h
AccountStateCache.h
catapult::cache::AccountStateCache
Synchronized cache composed of stateful account information.
Definition: AccountStateCache.h:72
Observers.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::observers::ObserverContext::Height
const catapult::Height Height
Current height.
Definition: ObserverContext.h:92
ExpiredLockInfoObserver.h