forked from qdrvm/kagome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_repository.hpp
46 lines (37 loc) · 1.17 KB
/
module_repository.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <memory>
#include <span>
#include "host_api/host_api.hpp"
#include "outcome/outcome.hpp"
#include "primitives/block_data.hpp"
namespace kagome::runtime {
class ModuleInstance;
class Module;
class Memory;
class RuntimeCodeProvider;
/**
* Repository for runtime modules
* Allows loading and compiling a module directly from its web assembly byte
* code and instantiating a runtime module at an arbitrary block
*/
class ModuleRepository {
public:
virtual ~ModuleRepository() = default;
/**
* @brief Returns a module instance for runtime at the \arg block state,
* loading its code using the provided \arg code_provider
* @param block info of the block at which the runtime code should be
* extracted
* @param state_hash of the block at which the runtime code should be
* extracted
*/
virtual outcome::result<std::shared_ptr<ModuleInstance>> getInstanceAt(
const primitives::BlockInfo &block,
const storage::trie::RootHash &state_hash) = 0;
};
} // namespace kagome::runtime