[−][src]Trait frame_support::storage::generator::StorageDoubleMap
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.
Required methods
fn module_prefix() -> &'static [u8]
Module prefix. Used for generating final key.
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.
Provided methods
fn storage_double_map_final_key1<KArg1>(k1: KArg1) -> Vec<u8> where
KArg1: EncodeLike<K1>,
KArg1: EncodeLike<K1>,
Generate the first part of the key used in top storage.
fn storage_double_map_final_key<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Vec<u8> where
KArg1: EncodeLike<K1>,
KArg2: EncodeLike<K2>,
KArg1: EncodeLike<K1>,
KArg2: EncodeLike<K2>,
Generate the full key used in top storage.