Kagome
Polkadot Runtime Engine in C++17
child_storage_extension.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_HOST_API_CHILD_STORAGE_EXTENSION_HPP
7 #define KAGOME_HOST_API_CHILD_STORAGE_EXTENSION_HPP
8 
9 #include <cstdint>
10 
11 #include "common/buffer.hpp"
12 #include "log/logger.hpp"
13 #include "runtime/types.hpp"
14 
15 namespace kagome::runtime {
16  class MemoryProvider;
17  class TrieStorageProvider;
18  class Memory;
19 } // namespace kagome::runtime
20 
21 namespace kagome::host_api {
26  public:
28  std::shared_ptr<runtime::TrieStorageProvider> storage_provider,
29  std::shared_ptr<const runtime::MemoryProvider> memory_provider);
30 
31  // ---------------------------- Child Storage ----------------------------
32 
36  void ext_default_child_storage_set_version_1(
37  runtime::WasmSpan child_storage_key,
39  runtime::WasmSpan value);
40 
44  runtime::WasmSpan ext_default_child_storage_get_version_1(
45  runtime::WasmSpan child_storage_key, runtime::WasmSpan key) const;
46 
50  void ext_default_child_storage_clear_version_1(
51  runtime::WasmSpan child_storage_key, runtime::WasmSpan key);
52 
56  runtime::WasmSpan ext_default_child_storage_next_key_version_1(
57  runtime::WasmSpan child_storage_key, runtime::WasmSpan key) const;
58 
62  runtime::WasmSpan ext_default_child_storage_root_version_1(
63  runtime::WasmSpan child_storage_key) const;
64 
68  void ext_default_child_storage_clear_prefix_version_1(
69  runtime::WasmSpan child_storage_key, runtime::WasmSpan prefix);
70 
74  runtime::WasmSpan ext_default_child_storage_read_version_1(
75  runtime::WasmSpan child_storage_key,
77  runtime::WasmSpan value_out,
78  runtime::WasmOffset offset) const;
79 
83  uint32_t ext_default_child_storage_exists_version_1(
84  runtime::WasmSpan child_storage_key, runtime::WasmSpan key) const;
85 
89  void ext_default_child_storage_storage_kill_version_1(
90  runtime::WasmSpan child_storage_key);
91 
92  private:
93  std::shared_ptr<runtime::TrieStorageProvider> storage_provider_;
94  std::shared_ptr<const runtime::MemoryProvider> memory_provider_;
96 
97  constexpr static auto kDefaultLoggerTag =
98  "WASM Runtime [ChildStorageExtension]";
99 
100  template <typename R, typename F, typename... Args>
101  outcome::result<R> executeOnChildStorage(
102  const common::Buffer &child_storage_key, F func, Args &&...args) const;
103  };
104 
105 } // namespace kagome::host_api
106 
107 #endif // KAGOME_CHILD_STORAGE_HostApiS_HostApi_HPP
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
uint32_t WasmOffset
Offset type is uint32_t because we are working in 32 bit address space.
Definition: types.hpp:44
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
std::shared_ptr< const runtime::MemoryProvider > memory_provider_
uint64_t WasmSpan
combination of pointer and size, where less significant part represents wasm pointer, and most significant represents size
Definition: types.hpp:31
std::shared_ptr< runtime::TrieStorageProvider > storage_provider_