CatapultServer  v0.5.0.1 (Elephant)
MosaicSupplyChangeObserver.cpp File Reference
Include dependency graph for MosaicSupplyChangeObserver.cpp:

Namespaces

 catapult
 
 catapult::observers
 

Functions

 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);} })