[−][src]Trait frame_support::storage::generator::LinkedMapKeyFormat
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.
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 head_prefix() -> &'static [u8]
Storage prefix. Used for generating final head key.
Provided methods
fn storage_linked_map_final_key<K>(key: &K) -> Vec<u8> where
K: Encode,
K: Encode,
Generate the full key used in top storage.
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.