mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 17:21:08 +00:00
Translation for linked map (#4052)
* make linked_map generic functions better * implement translation of linked map * proc-macro for linked map updated * test linked map migration * account for instances * address grumbles * cut map short if migration fails
This commit is contained in:
committed by
Gavin Wood
parent
05391f7e04
commit
2eac9f5b1b
@@ -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).
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user