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

pub trait LinkedMapKeyFormat {
    type Hasher: StorageHasher;
    fn module_prefix() -> &'static [u8];
fn storage_prefix() -> &'static [u8];
fn head_prefix() -> &'static [u8]; fn storage_linked_map_final_key<K>(key: &K) -> Vec<u8>
    where
        K: Encode
, { ... }
fn storage_linked_map_final_head_key() -> Vec<u8> { ... } }

A type-abstracted key format used for a family of linked-map types.

Default mapping of keys to a storage path

The key for the head of the map is stored at one fixed path:

Twox128(module_prefix) ++ Twox128(head_prefix)

For each key, the value stored under that key is appended with a Linkage (which hold previous and next key) at the path:

Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher(encode(key))

Enumeration is done by getting the head of the linked map and then iterating getting the value and linkage stored at the key until the found linkage has no next key.

Warning

If the keys are not trusted (e.g. can be set by a user), a cryptographic hasher such as blake2_256 must be used. Otherwise, other values in storage can be compromised.

Associated Types

type Hasher: StorageHasher

Hasher. Used for generating final key and final head 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.

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

Storage prefix. Used for generating final head key.

Loading content...

Provided methods

Important traits for Vec<u8>
fn storage_linked_map_final_key<K>(key: &K) -> Vec<u8> where
    K: Encode

Generate the full key used in top storage.

Important traits for Vec<u8>
fn storage_linked_map_final_head_key() -> Vec<u8>

Generate the full key used in top storage to store the head of the linked map.

Loading content...

Implementors

Loading content...