[][src]Trait frame_support::storage::generator::StorageDoubleMap

pub trait StorageDoubleMap<K1: FullEncode, K2: FullEncode, V: FullCodec> {
    type Query;
    type Hasher1: StorageHasher;
    type Hasher2: StorageHasher;
    fn module_prefix() -> &'static [u8];
fn storage_prefix() -> &'static [u8];
fn from_optional_value_to_query(v: Option<V>) -> Self::Query;
fn from_query_to_optional_value(v: Self::Query) -> Option<V>; fn storage_double_map_final_key1<KArg1>(k1: KArg1) -> Vec<u8>
    where
        KArg1: EncodeLike<K1>
, { ... }
fn storage_double_map_final_key<KArg1, KArg2>(
        k1: KArg1,
        k2: KArg2
    ) -> Vec<u8>
    where
        KArg1: EncodeLike<K1>,
        KArg2: EncodeLike<K2>
, { ... } }

Generator for StorageDoubleMap used by decl_storage.

Mapping of keys to a storage path

The storage key (i.e. the key under which the Value will be stored) is created from two parts. The first part is a hash of a concatenation of the key1_prefix and Key1. And the second part is a hash of a Key2.

Thus value for (key1, key2) is stored at:

Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher1(encode(key1)) ++ Hasher2(encode(key2))

Warning

If the key1s are not trusted (e.g. can be set by a user), a cryptographic hasher such as blake2_256 must be used for Hasher1. Otherwise, other values in storage can be compromised. If the key2s are not trusted (e.g. can be set by a user), a cryptographic hasher such as blake2_256 must be used for Hasher2. Otherwise, other items in storage with the same first key can be compromised.

Associated Types

type Query

The type that get/take returns.

type Hasher1: StorageHasher

Hasher for the first key.

type Hasher2: StorageHasher

Hasher for the second key.

Loading content...

Required methods

Important traits for &'_ mut [u8]
fn module_prefix() -> &'static [u8]

Module prefix. Used for generating final key.

Important traits for &'_ mut [u8]
fn storage_prefix() -> &'static [u8]

Storage prefix. Used for generating final key.

fn from_optional_value_to_query(v: Option<V>) -> Self::Query

Convert an optional value retrieved from storage to the type queried.

fn from_query_to_optional_value(v: Self::Query) -> Option<V>

Convert a query to an optional value into storage.

Loading content...

Provided methods

Important traits for Vec<u8>
fn storage_double_map_final_key1<KArg1>(k1: KArg1) -> Vec<u8> where
    KArg1: EncodeLike<K1>, 

Generate the first part of the key used in top storage.

Important traits for Vec<u8>
fn storage_double_map_final_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Vec<u8> where
    KArg1: EncodeLike<K1>,
    KArg2: EncodeLike<K2>, 

Generate the full key used in top storage.

Loading content...

Implementors

Loading content...