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