Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Translation for linked map #4052

Merged
merged 8 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions srml/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ use proc_macro::TokenStream;
/// * `head_key`: `"head of " ++ $module_prefix ++ " " ++ $storage_name`
/// * `Hasher`: $hash
///
/// All key formatting logic can be accessed in a type-agnostic format via the
/// [`KeyFormat`](../srml_support/storage/generator/trait.KeyFormat.html) trait, which
/// is implemented for the storage linked map type as well.
///
/// * Double map: `Foo: double_map hasher($hash1) u32, $hash2(u32) => u32`: Implements the
/// [`StorageDoubleMap`](../srml_support/storage/trait.StorageDoubleMap.html) trait using the
/// [`StorageDoubleMap generator`](../srml_support/storage/generator/trait.StorageDoubleMap.html).
Expand Down
13 changes: 9 additions & 4 deletions srml/support/procedural/src/storage/storage_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,12 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre
{
type Query = #query_type;
type Hasher = #scrate::#hasher;
type KeyFormat = Self;

fn prefix() -> &'static [u8] {
#final_prefix
}

fn head_key() -> &'static [u8] {
#head_key
}

fn from_optional_value_to_query(v: Option<#value_type>) -> Self::Query {
#from_optional_value_to_query
}
Expand All @@ -179,6 +176,14 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre
#from_query_to_optional_value
}
}

impl<#impl_trait> #scrate::storage::generator::LinkedMapKeyFormat for #storage_struct {
type Hasher = #scrate::#hasher;

fn head_key() -> &'static [u8] {
#head_key
}
}
)
},
StorageLineTypeDef::DoubleMap(map) => {
Expand Down
Loading