-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathmodule_repository.hpp
54 lines (44 loc) · 1.43 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
47
48
49
50
51
52
53
54
/**
* 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"
#include "primitives/version.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. The instance
* may be reused.
* @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;
/**
* Return cached `readEmbeddedVersion` result.
*/
virtual outcome::result<std::optional<primitives::Version>> embeddedVersion(
const primitives::BlockHash &block_hash) = 0;
};
} // namespace kagome::runtime