Kagome
Polkadot Runtime Engine in C++17
kagome::host_api::StorageExtension Class Reference

#include <storage_extension.hpp>

Collaboration diagram for kagome::host_api::StorageExtension:

Public Member Functions

 StorageExtension (std::shared_ptr< runtime::TrieStorageProvider > storage_provider, std::shared_ptr< const runtime::MemoryProvider > memory_provider)
 
void reset ()
 
runtime::WasmSpan ext_storage_read_version_1 (runtime::WasmSpan key, runtime::WasmSpan value_out, runtime::WasmOffset offset)
 
void ext_storage_set_version_1 (runtime::WasmSpan key, runtime::WasmSpan value)
 
runtime::WasmSpan ext_storage_get_version_1 (runtime::WasmSpan key)
 
void ext_storage_clear_version_1 (runtime::WasmSpan key_data)
 
runtime::WasmSize ext_storage_exists_version_1 (runtime::WasmSpan key_data) const
 
void ext_storage_clear_prefix_version_1 (runtime::WasmSpan prefix)
 
runtime::WasmSpan ext_storage_clear_prefix_version_2 (runtime::WasmSpan prefix, runtime::WasmSpan limit)
 
runtime::WasmSpan ext_storage_root_version_1 ()
 
runtime::WasmSpan ext_storage_root_version_2 (runtime::WasmI32 state_version)
 
runtime::WasmSpan ext_storage_changes_root_version_1 (runtime::WasmSpan parent_hash)
 
runtime::WasmSpan ext_storage_next_key_version_1 (runtime::WasmSpan key) const
 
void ext_storage_append_version_1 (runtime::WasmSpan key, runtime::WasmSpan value) const
 
void ext_storage_start_transaction_version_1 ()
 
void ext_storage_commit_transaction_version_1 ()
 
void ext_storage_rollback_transaction_version_1 ()
 
runtime::WasmPointer ext_trie_blake2_256_root_version_1 (runtime::WasmSpan values_data)
 
runtime::WasmPointer ext_trie_blake2_256_ordered_root_version_1 (runtime::WasmSpan values_data)
 
runtime::WasmPointer ext_trie_blake2_256_ordered_root_version_2 (runtime::WasmSpan values_data, runtime::WasmI32 state_version)
 

Private Member Functions

outcome::result< std::optional< common::BufferConstRef > > get (const common::BufferView &key) const
 
common::Buffer loadKey (runtime::WasmSpan key) const
 
outcome::result< std::optional< common::Buffer > > getStorageNextKey (const common::Buffer &key) const
 
runtime::WasmSpan clearPrefix (common::BufferView prefix, std::optional< uint32_t > limit)
 
void removeEmptyChildStorages ()
 

Private Attributes

std::shared_ptr< runtime::TrieStorageProviderstorage_provider_
 
std::shared_ptr< const runtime::MemoryProvidermemory_provider_
 
storage::trie::PolkadotCodec codec_
 
log::Logger logger_
 

Static Private Attributes

static constexpr auto kDefaultLoggerTag = "WASM Runtime [StorageExtension]"
 

Detailed Description

Implements HostApi functions related to storage

Definition at line 24 of file storage_extension.hpp.

Constructor & Destructor Documentation

kagome::host_api::StorageExtension::StorageExtension ( std::shared_ptr< runtime::TrieStorageProvider storage_provider,
std::shared_ptr< const runtime::MemoryProvider memory_provider 
)

Definition at line 41 of file storage_extension.cpp.

Member Function Documentation

runtime::WasmSpan kagome::host_api::StorageExtension::clearPrefix ( common::BufferView  prefix,
std::optional< uint32_t >  limit 
)
private

Definition at line 439 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::ext_storage_append_version_1 ( runtime::WasmSpan  key,
runtime::WasmSpan  value 
) const
runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_changes_root_version_1 ( runtime::WasmSpan  parent_hash)
void kagome::host_api::StorageExtension::ext_storage_clear_prefix_version_1 ( runtime::WasmSpan  prefix)
runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_clear_prefix_version_2 ( runtime::WasmSpan  prefix,
runtime::WasmSpan  limit 
)
void kagome::host_api::StorageExtension::ext_storage_clear_version_1 ( runtime::WasmSpan  key_data)
See also
HostApi::ext_storage_clear_version_1

Definition at line 163 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::ext_storage_commit_transaction_version_1 ( )
runtime::WasmSize kagome::host_api::StorageExtension::ext_storage_exists_version_1 ( runtime::WasmSpan  key_data) const
runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_get_version_1 ( runtime::WasmSpan  key)
See also
HostApi::ext_storage_get_version_1

Definition at line 140 of file storage_extension.cpp.

runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_next_key_version_1 ( runtime::WasmSpan  key) const
See also
HostApi::ext_storage_next_key

Definition at line 257 of file storage_extension.cpp.

runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_read_version_1 ( runtime::WasmSpan  key,
runtime::WasmSpan  value_out,
runtime::WasmOffset  offset 
)
See also
HostApi::ext_storage_read_version_1

Definition at line 68 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::ext_storage_rollback_transaction_version_1 ( )
runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_root_version_1 ( )
See also
HostApi::ext_storage_root_version_1

Definition at line 224 of file storage_extension.cpp.

runtime::WasmSpan kagome::host_api::StorageExtension::ext_storage_root_version_2 ( runtime::WasmI32  state_version)
See also
HostApi::ext_storage_root_version_2

Definition at line 228 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::ext_storage_set_version_1 ( runtime::WasmSpan  key,
runtime::WasmSpan  value 
)
See also
HostApi::ext_storage_set_version_1

Definition at line 121 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::ext_storage_start_transaction_version_1 ( )
runtime::WasmPointer kagome::host_api::StorageExtension::ext_trie_blake2_256_ordered_root_version_1 ( runtime::WasmSpan  values_data)
runtime::WasmPointer kagome::host_api::StorageExtension::ext_trie_blake2_256_ordered_root_version_2 ( runtime::WasmSpan  values_data,
runtime::WasmI32  state_version 
)
runtime::WasmPointer kagome::host_api::StorageExtension::ext_trie_blake2_256_root_version_1 ( runtime::WasmSpan  values_data)
outcome::result< std::optional< common::BufferConstRef > > kagome::host_api::StorageExtension::get ( const common::BufferView key) const
private

Find the value by given key and the return the part of it starting from given offset

Parameters
keyBuffer representation of the key
Returns
result containing Buffer with the value

Definition at line 101 of file storage_extension.cpp.

outcome::result< std::optional< Buffer > > kagome::host_api::StorageExtension::getStorageNextKey ( const common::Buffer key) const
private
Returns
error if any, a key if the next key exists none otherwise

Definition at line 113 of file storage_extension.cpp.

common::Buffer kagome::host_api::StorageExtension::loadKey ( runtime::WasmSpan  key) const
private

Read key in form of [ptr; size] and load its value from memory into buffer

Parameters
keyrepresentation by [ptr; size]
Returns
result containing Buffer with the key

Definition at line 107 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::removeEmptyChildStorages ( )
private

Removes all empty child storages from the primary storage. Such cleanup is required for the correct storage root calculation.

Definition at line 462 of file storage_extension.cpp.

void kagome::host_api::StorageExtension::reset ( )

Definition at line 51 of file storage_extension.cpp.

Member Data Documentation

storage::trie::PolkadotCodec kagome::host_api::StorageExtension::codec_
private

Definition at line 175 of file storage_extension.hpp.

constexpr auto kagome::host_api::StorageExtension::kDefaultLoggerTag = "WASM Runtime [StorageExtension]"
staticprivate

Definition at line 178 of file storage_extension.hpp.

log::Logger kagome::host_api::StorageExtension::logger_
private

Definition at line 176 of file storage_extension.hpp.

std::shared_ptr<const runtime::MemoryProvider> kagome::host_api::StorageExtension::memory_provider_
private

Definition at line 174 of file storage_extension.hpp.

std::shared_ptr<runtime::TrieStorageProvider> kagome::host_api::StorageExtension::storage_provider_
private

Definition at line 173 of file storage_extension.hpp.


The documentation for this class was generated from the following files: