22 const std::vector<uint8_t> &code,
23 std::shared_ptr<const InstanceEnvironmentFactory> env_factory,
32 std::shared_ptr<const RuntimeCodeProvider>,
39 OUTCOME_TRY(inst, module->instantiate());
48 const std::vector<uint8_t> &
code_;
56 virtual outcome::result<gsl::span<const uint8_t>>
getCodeAt(
66 std::shared_ptr<const InstanceEnvironmentFactory> instance_env_factory,
67 std::shared_ptr<const blockchain::BlockHeaderRepository> header_repo,
68 std::shared_ptr<storage::changes_trie::ChangesTracker> changes_tracker,
69 std::shared_ptr<runtime::RuntimePropertiesCache> cache)
70 : instance_env_factory_{std::move(instance_env_factory)},
77 BOOST_ASSERT(
cache_ !=
nullptr);
81 std::shared_ptr<const crypto::Hasher> hasher,
82 const std::vector<uint8_t> &runtime_code)
const {
83 auto code_hash = hasher->sha2_256(runtime_code);
84 auto env_factory = std::make_shared<runtime::RuntimeEnvironmentFactory>(
85 std::make_shared<OneCodeProvider>(runtime_code),
86 std::make_shared<OneModuleRepository>(
89 auto executor = std::make_unique<Executor>(env_factory,
cache_);
90 return std::make_unique<CoreImpl>(
std::unique_ptr< Core > make(std::shared_ptr< const crypto::Hasher > hasher, const std::vector< uint8_t > &runtime_code) const override
virtual outcome::result< gsl::span< const uint8_t > > getCodeAt(const storage::trie::RootHash &) const
const std::vector< uint8_t > & code_
std::shared_ptr< ModuleInstance > instance_
std::shared_ptr< runtime::RuntimePropertiesCache > cache_
const common::Hash256 code_hash_
std::shared_ptr< storage::changes_trie::ChangesTracker > changes_tracker_
std::shared_ptr< const InstanceEnvironmentFactory > env_factory_
gsl::span< const uint8_t > code_
OneModuleRepository(const std::vector< uint8_t > &code, std::shared_ptr< const InstanceEnvironmentFactory > env_factory, const common::Hash256 &code_hash)
outcome::result< std::shared_ptr< ModuleInstance > > getInstanceAt(std::shared_ptr< const RuntimeCodeProvider >, const primitives::BlockInfo &, const primitives::BlockHeader &) override
Returns a module instance for runtime at the.
CoreApiFactoryImpl(std::shared_ptr< const InstanceEnvironmentFactory > instance_env_factory, std::shared_ptr< const blockchain::BlockHeaderRepository > header_repo, std::shared_ptr< storage::changes_trie::ChangesTracker > changes_tracker, std::shared_ptr< runtime::RuntimePropertiesCache > cache)
std::shared_ptr< const blockchain::BlockHeaderRepository > header_repo_
static outcome::result< std::unique_ptr< ModuleImpl > > createFromCode(const std::vector< uint8_t > &code, std::shared_ptr< const InstanceEnvironmentFactory > env_factory_, const common::Hash256 &code_hash)
OneCodeProvider(gsl::span< const uint8_t > code)
std::shared_ptr< const InstanceEnvironmentFactory > instance_env_factory_