Kagome
Polkadot Runtime Engine in C++17
runtime_properties_cache_impl.cpp
Go to the documentation of this file.
1 
7 
8 namespace kagome::runtime {
9 
10  outcome::result<primitives::Version> RuntimePropertiesCacheImpl::getVersion(
11  const common::Hash256 &hash,
12  std::function<outcome::result<primitives::Version>()> obtainer) {
13  auto it = cached_versions_.find(hash);
14  if (it == cached_versions_.end()) {
15  OUTCOME_TRY(version, obtainer());
16  it = cached_versions_.emplace(hash, std::move(version)).first;
17  }
18  return it->second;
19  }
20 
21  outcome::result<primitives::OpaqueMetadata>
23  const common::Hash256 &hash,
24  std::function<outcome::result<primitives::OpaqueMetadata>()> obtainer) {
25  auto it = cached_metadata_.find(hash);
26  if (it == cached_metadata_.end()) {
27  OUTCOME_TRY(metadata, obtainer());
28  it = cached_metadata_.emplace(hash, std::move(metadata)).first;
29  }
30  return it->second;
31  }
32 
33 } // namespace kagome::runtime
std::map< common::Hash256, primitives::Version > cached_versions_
std::map< common::Hash256, primitives::OpaqueMetadata > cached_metadata_
string version
Definition: conf.py:16
outcome::result< primitives::Version > getVersion(const common::Hash256 &hash, std::function< outcome::result< primitives::Version >()> obtainer) override
outcome::result< primitives::OpaqueMetadata > getMetadata(const common::Hash256 &hash, std::function< outcome::result< primitives::OpaqueMetadata >()> obtainer) override