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

Namespaces

 catapult
 
 catapult::validators
 

Functions

 catapult::validators::DEFINE_STATEFUL_VALIDATOR (AccountLinkAvailability, [](const auto &notification, const auto &context) { const auto &cache=context.Cache.template sub< cache::AccountStateCache >();auto accountStateIter=cache.find(notification.MainAccountKey);const auto &accountState=accountStateIter.get();if(model::AccountLinkAction::Link==notification.LinkAction) { if(state::AccountType::Unlinked !=accountState.AccountType) return Failure_AccountLink_Link_Already_Exists;} else { if(state::AccountType::Main !=accountState.AccountType) return Failure_AccountLink_Link_Does_Not_Exist;if(notification.RemoteAccountKey !=accountState.LinkedAccountKey) return Failure_AccountLink_Unlink_Data_Inconsistency;} return ValidationResult::Success;})