mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 08:31:14 +00:00
Refactor StorageInstance trait to be usable more easily (#7659)
* refactor StorageInstance to be usable without macros * better description * update types doc * Update frame/support/src/traits.rs 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:
committed by
GitHub
parent
b149b1fdc0
commit
7e83b7a7f2
@@ -1731,13 +1731,19 @@ pub trait Instance: 'static {
|
||||
const PREFIX: &'static str;
|
||||
}
|
||||
|
||||
/// An instance of a storage.
|
||||
/// An instance of a storage in a pallet.
|
||||
///
|
||||
/// It is required the the couple `(PalletInfo::name<Pallet>(), STORAGE_PREFIX)` is unique.
|
||||
/// Any storage with same couple will collide.
|
||||
/// Define an instance for an individual storage inside a pallet.
|
||||
/// The pallet prefix is used to isolate the storage between pallets, and the storage prefix is
|
||||
/// used to isolate storages inside a pallet.
|
||||
///
|
||||
/// NOTE: These information can be used to define storages in pallet such as a `StorageMap` which
|
||||
/// can use keys after `twox_128(pallet_prefix())++twox_128(STORAGE_PREFIX)`
|
||||
pub trait StorageInstance {
|
||||
type Pallet: 'static;
|
||||
type PalletInfo: PalletInfo;
|
||||
/// Prefix of a pallet to isolate it from other pallets.
|
||||
fn pallet_prefix() -> &'static str;
|
||||
|
||||
/// Prefix given to a storage to isolate from other storages in the pallet.
|
||||
const STORAGE_PREFIX: &'static str;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user