mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 12:48:00 +00:00
Modify doublemap syntax (#4576)
* modify doublemap syntax * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -117,7 +117,7 @@ use proc_macro::TokenStream;
|
||||
/// Twox128(module_prefix) ++ Twox128(head_prefix)
|
||||
/// ```
|
||||
///
|
||||
/// * Double map: `Foo: double_map hasher($hash1) u32, $hash2(u32) => u32`: Implements the
|
||||
/// * Double map: `Foo: double_map hasher($hash1) u32, hasher($hash2) u32 => u32`: Implements the
|
||||
/// [`StorageDoubleMap`](../frame_support/storage/trait.StorageDoubleMap.html) trait using the
|
||||
/// [`StorageDoubleMap generator`](../frame_support/storage/generator/trait.StorageDoubleMap.html).
|
||||
/// And [`StoragePrefixedMap`](../frame_support/storage/trait.StoragePrefixedMap.html).
|
||||
@@ -126,10 +126,8 @@ use proc_macro::TokenStream;
|
||||
/// [`Hashable`](../frame_support/trait.Hashable.html) trait. They must be choosen with care, see
|
||||
/// generator documentation.
|
||||
///
|
||||
/// `hasher($hash)` is optional and its default is `blake2_256`.
|
||||
///
|
||||
/// `hasher($hash)` is optional and its default is `blake2_256`. One should use another hasher
|
||||
/// with care, see generator documentation.
|
||||
/// `hasher($hash1)` and `hasher($hash2) are optional and default to `blake2_256`.
|
||||
/// One should use another hasher with care, see generator documentation.
|
||||
///
|
||||
/// If the first key is untrusted, a cryptographic `hasher` such as `blake2_256` must be used.
|
||||
/// Otherwise, other values of all storage items can be compromised.
|
||||
|
||||
@@ -167,11 +167,11 @@ struct DeclStorageLinkedMap {
|
||||
#[derive(Parse, ToTokens, Debug)]
|
||||
struct DeclStorageDoubleMap {
|
||||
pub map_keyword: keyword::double_map,
|
||||
pub hasher: ext::Opt<SetHasher>,
|
||||
pub hasher1: ext::Opt<SetHasher>,
|
||||
pub key1: syn::Type,
|
||||
pub comma_keyword: Token![,],
|
||||
pub key2_hasher: Hasher,
|
||||
pub key2: ext::Parens<syn::Type>,
|
||||
pub hasher2: ext::Opt<SetHasher>,
|
||||
pub key2: syn::Type,
|
||||
pub ass_keyword: Token![=>],
|
||||
pub value: syn::Type,
|
||||
}
|
||||
@@ -380,11 +380,12 @@ fn parse_storage_line_defs(
|
||||
),
|
||||
DeclStorageType::DoubleMap(map) => super::StorageLineTypeDef::DoubleMap(
|
||||
super::DoubleMapDef {
|
||||
hasher1: map.hasher.inner.map(Into::into)
|
||||
hasher1: map.hasher1.inner.map(Into::into)
|
||||
.unwrap_or(super::HasherKind::Blake2_256),
|
||||
hasher2: map.hasher2.inner.map(Into::into)
|
||||
.unwrap_or(super::HasherKind::Blake2_256),
|
||||
hasher2: map.key2_hasher.into(),
|
||||
key1: map.key1,
|
||||
key2: map.key2.content,
|
||||
key2: map.key2,
|
||||
value: map.value,
|
||||
}
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user