mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 03:27:58 +00:00
Allow to specify some max number of values for storages in pallet macro. (#8735)
* implement max_values + storages info * some formatting + doc * rename StoragesInfo -> PalletStorageInfo * merge both StorageInfoTrait and PalletStorageInfo I think it is more future proof. In the future some storage could make use of multiple prefix. Like one to store how much value has been inserted, etc... * Update frame/support/procedural/src/storage/parse.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Update frame/support/procedural/src/storage/storage_struct.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Fix max_size using hasher information hasher now expose `max_len` which allows to computes their maximum len. For hasher without concatenation, it is the size of the hash part, for hasher with concatenation, it is the size of the hash part + max encoded len of the key. * fix tests * fix ui tests Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
59f34ab8bc
commit
9bf62ef65d
@@ -156,6 +156,9 @@ use proc_macro::TokenStream;
|
||||
/// * \[optional\] `config(#field_name)`: `field_name` is optional if get is set.
|
||||
/// Will include the item in `GenesisConfig`.
|
||||
/// * \[optional\] `build(#closure)`: Closure called with storage overlays.
|
||||
/// * \[optional\] `max_values(#expr)`: `expr` is an expression returning a `u32`. It is used to
|
||||
/// implement `StorageInfoTrait`. Note this attribute is not available for storage value as the maximum
|
||||
/// number of values is 1.
|
||||
/// * `#type`: Storage type.
|
||||
/// * \[optional\] `#default`: Value returned when none.
|
||||
///
|
||||
@@ -234,11 +237,20 @@ use proc_macro::TokenStream;
|
||||
/// add_extra_genesis {
|
||||
/// config(phantom): std::marker::PhantomData<I>,
|
||||
/// }
|
||||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// This adds a field to your `GenesisConfig` with the name `phantom` that you can initialize with
|
||||
/// `Default::default()`.
|
||||
///
|
||||
/// ## PoV information
|
||||
///
|
||||
/// To implement the trait `StorageInfoTrait` for storages an additional attribute can be used
|
||||
/// `generate_storage_info`:
|
||||
/// ```nocompile
|
||||
/// decl_storage! { generate_storage_info
|
||||
/// trait Store for ...
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro]
|
||||
pub fn decl_storage(input: TokenStream) -> TokenStream {
|
||||
storage::decl_storage_impl(input)
|
||||
|
||||
Reference in New Issue
Block a user