mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +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
@@ -34,7 +34,7 @@ use sp_std::vec::Vec;
|
||||
///
|
||||
/// Each value is stored at:
|
||||
/// ```nocompile
|
||||
/// Twox128(<Prefix::Pallet as PalletInfo>::name())
|
||||
/// Twox128(Prefix::pallet_prefix())
|
||||
/// ++ Twox128(Prefix::STORAGE_PREFIX)
|
||||
/// ++ Hasher1(encode(key1))
|
||||
/// ++ Hasher2(encode(key2))
|
||||
@@ -68,8 +68,7 @@ where
|
||||
type Hasher1 = Hasher1;
|
||||
type Hasher2 = Hasher2;
|
||||
fn module_prefix() -> &'static [u8] {
|
||||
<Prefix::PalletInfo as crate::traits::PalletInfo>::name::<Prefix::Pallet>()
|
||||
.expect("Every active pallet has a name in the runtime; qed").as_bytes()
|
||||
Prefix::pallet_prefix().as_bytes()
|
||||
}
|
||||
fn storage_prefix() -> &'static [u8] {
|
||||
Prefix::STORAGE_PREFIX.as_bytes()
|
||||
@@ -415,8 +414,7 @@ mod test {
|
||||
|
||||
struct Prefix;
|
||||
impl StorageInstance for Prefix {
|
||||
type Pallet = ();
|
||||
type PalletInfo = ();
|
||||
fn pallet_prefix() -> &'static str { "test" }
|
||||
const STORAGE_PREFIX: &'static str = "foo";
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use sp_std::prelude::*;
|
||||
///
|
||||
/// Each value is stored at:
|
||||
/// ```nocompile
|
||||
/// Twox128(<Prefix::Pallet as PalletInfo>::name())
|
||||
/// Twox128(Prefix::pallet_prefix())
|
||||
/// ++ Twox128(Prefix::STORAGE_PREFIX)
|
||||
/// ++ Hasher1(encode(key))
|
||||
/// ```
|
||||
@@ -60,8 +60,7 @@ where
|
||||
type Query = QueryKind::Query;
|
||||
type Hasher = Hasher;
|
||||
fn module_prefix() -> &'static [u8] {
|
||||
<Prefix::PalletInfo as crate::traits::PalletInfo>::name::<Prefix::Pallet>()
|
||||
.expect("Every active pallet has a name in the runtime; qed").as_bytes()
|
||||
Prefix::pallet_prefix().as_bytes()
|
||||
}
|
||||
fn storage_prefix() -> &'static [u8] {
|
||||
Prefix::STORAGE_PREFIX.as_bytes()
|
||||
@@ -318,8 +317,7 @@ mod test {
|
||||
|
||||
struct Prefix;
|
||||
impl StorageInstance for Prefix {
|
||||
type Pallet = ();
|
||||
type PalletInfo = ();
|
||||
fn pallet_prefix() -> &'static str { "test" }
|
||||
const STORAGE_PREFIX: &'static str = "foo";
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ use frame_metadata::{DefaultByteGetter, StorageEntryModifier};
|
||||
///
|
||||
/// Each value is stored at:
|
||||
/// ```nocompile
|
||||
/// Twox128(<Prefix::Pallet as PalletInfo>::name()) ++ Twox128(Prefix::STORAGE_PREFIX)
|
||||
/// Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)
|
||||
/// ```
|
||||
pub struct StorageValue<Prefix, Value, QueryKind=OptionQuery, OnEmpty=GetDefault>(
|
||||
core::marker::PhantomData<(Prefix, Value, QueryKind, OnEmpty)>
|
||||
@@ -47,8 +47,7 @@ where
|
||||
{
|
||||
type Query = QueryKind::Query;
|
||||
fn module_prefix() -> &'static [u8] {
|
||||
<Prefix::PalletInfo as crate::traits::PalletInfo>::name::<Prefix::Pallet>()
|
||||
.expect("Every active pallet has a name in the runtime; qed").as_bytes()
|
||||
Prefix::pallet_prefix().as_bytes()
|
||||
}
|
||||
fn storage_prefix() -> &'static [u8] {
|
||||
Prefix::STORAGE_PREFIX.as_bytes()
|
||||
@@ -201,8 +200,7 @@ mod test {
|
||||
|
||||
struct Prefix;
|
||||
impl StorageInstance for Prefix {
|
||||
type Pallet = ();
|
||||
type PalletInfo = ();
|
||||
fn pallet_prefix() -> &'static str { "test" }
|
||||
const STORAGE_PREFIX: &'static str = "foo";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user