Kagome
Polkadot Runtime Engine in C++17
instance_environment_factory.cpp
Go to the documentation of this file.
1 
7 
12 
13 namespace kagome::runtime::binaryen {
14 
16  std::shared_ptr<storage::trie::TrieStorage> storage,
17  std::shared_ptr<storage::trie::TrieSerializer> serializer,
18  std::shared_ptr<host_api::HostApiFactory> host_api_factory,
19  std::shared_ptr<blockchain::BlockHeaderRepository> block_header_repo,
20  std::shared_ptr<storage::changes_trie::ChangesTracker> changes_tracker,
21  std::shared_ptr<runtime::RuntimePropertiesCache> cache)
22  : storage_{std::move(storage)},
23  serializer_{std::move(serializer)},
24  host_api_factory_{std::move(host_api_factory)},
25  block_header_repo_{std::move(block_header_repo)},
26  changes_tracker_{std::move(changes_tracker)},
27  cache_(std::move(cache)) {
28  BOOST_ASSERT(storage_);
29  BOOST_ASSERT(serializer_);
30  BOOST_ASSERT(host_api_factory_);
31  BOOST_ASSERT(block_header_repo_);
32  BOOST_ASSERT(changes_tracker_);
33  BOOST_ASSERT(cache_);
34  }
35 
37  auto memory_factory = std::make_shared<BinaryenMemoryFactory>();
38  auto new_memory_provider =
39  std::make_shared<BinaryenMemoryProvider>(memory_factory);
40  auto new_storage_provider =
41  std::make_shared<TrieStorageProviderImpl>(storage_, serializer_);
42  auto core_factory = std::make_shared<CoreApiFactoryImpl>(
43  shared_from_this(), block_header_repo_, changes_tracker_, cache_);
44  auto host_api = std::shared_ptr<host_api::HostApi>(host_api_factory_->make(
45  core_factory, new_memory_provider, new_storage_provider));
46  auto rei = std::make_shared<RuntimeExternalInterface>(host_api);
47  new_memory_provider->setExternalInterface(rei);
49  InstanceEnvironment{std::move(new_memory_provider),
50  std::move(new_storage_provider),
51  std::move(host_api),
52  [](auto &) {}},
53  std::move(rei)};
54  }
55 } // namespace kagome::runtime::binaryen
std::shared_ptr< storage::changes_trie::ChangesTracker > changes_tracker_
std::shared_ptr< runtime::RuntimePropertiesCache > cache_
InstanceEnvironment make(MemoryOrigin memory_origin, WAVM::Runtime::Instance *runtime_instance, std::shared_ptr< IntrinsicModuleInstance > intrinsic_instance) const
std::shared_ptr< storage::trie::TrieStorage > storage_
InstanceEnvironmentFactory(std::shared_ptr< storage::trie::TrieStorage > storage, std::shared_ptr< storage::trie::TrieSerializer > serializer, std::shared_ptr< host_api::HostApiFactory > host_api_factory, std::shared_ptr< blockchain::BlockHeaderRepository > block_header_repo, std::shared_ptr< storage::changes_trie::ChangesTracker > changes_tracker, std::shared_ptr< RuntimePropertiesCache > cache)
std::shared_ptr< blockchain::BlockHeaderRepository > block_header_repo_