Kagome
Polkadot Runtime Engine in C++17
module_factory_impl.cpp
Go to the documentation of this file.
1 
7 
8 #include "crypto/hasher.hpp"
12 
13 namespace kagome::runtime::wavm {
14 
16  std::shared_ptr<CompartmentWrapper> compartment,
17  std::shared_ptr<ModuleParams> module_params,
18  std::shared_ptr<const InstanceEnvironmentFactory> env_factory,
19  std::shared_ptr<IntrinsicModule> intrinsic_module,
20  std::optional<std::shared_ptr<ModuleCache>> module_cache,
21  std::shared_ptr<crypto::Hasher> hasher)
22  : compartment_{std::move(compartment)},
23  module_params_{std::move(module_params)},
24  env_factory_{std::move(env_factory)},
25  intrinsic_module_{std::move(intrinsic_module)},
26  hasher_(std::move(hasher)) {
27  BOOST_ASSERT(compartment_ != nullptr);
28  BOOST_ASSERT(module_params_ != nullptr);
29  BOOST_ASSERT(env_factory_ != nullptr);
30  BOOST_ASSERT(intrinsic_module_ != nullptr);
31  BOOST_ASSERT(hasher_ != nullptr);
32 
33  if (module_cache.has_value()) {
34  WAVM::Runtime::setGlobalObjectCache(std::move(module_cache.value()));
35  }
36  }
37 
38  outcome::result<std::unique_ptr<Module>> ModuleFactoryImpl::make(
39  gsl::span<const uint8_t> code) const {
44  code,
45  hasher_->sha2_256(code));
46  }
47 
48 } // namespace kagome::runtime::wavm
outcome::result< std::unique_ptr< Module > > make(gsl::span< const uint8_t > code) const override
std::shared_ptr< ModuleParams > module_params_
std::shared_ptr< CompartmentWrapper > compartment_
ModuleFactoryImpl(std::shared_ptr< CompartmentWrapper > compartment, std::shared_ptr< ModuleParams > module_params, std::shared_ptr< const InstanceEnvironmentFactory > env_factory, std::shared_ptr< IntrinsicModule > intrinsic_module, std::optional< std::shared_ptr< ModuleCache >> module_cache, std::shared_ptr< crypto::Hasher > hasher)
std::shared_ptr< IntrinsicModule > intrinsic_module_
std::shared_ptr< crypto::Hasher > hasher_
static std::unique_ptr< ModuleImpl > compileFrom(std::shared_ptr< CompartmentWrapper > compartment, ModuleParams &module_params, std::shared_ptr< IntrinsicModule > intrinsic_module, std::shared_ptr< const InstanceEnvironmentFactory > env_factory, gsl::span< const uint8_t > code, const common::Hash256 &code_hash)
Definition: module.cpp:23
std::shared_ptr< const InstanceEnvironmentFactory > env_factory_