mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 05:07:55 +00:00
BoundedVec + Shims for Append/DecodeLength (#8556)
* prototype for shawn * Clean and document it * Add more docs * Move imports * Some changes for easier compat. * revert exmaple pallet * rename * BoundedVec for AccountLocks (#8580) * Example with balances * Fix tests * Make it indexable * fix * Fix tests * fix test * Fix collective as well * Fix test * Update frame/support/src/storage/mod.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Repot and add for value * Add for map and double map * Final touches. * Update frame/support/src/storage/bounded_vec.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Add a few more tests * Add import Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -20,12 +20,16 @@
|
||||
use sp_core::storage::ChildInfo;
|
||||
use sp_std::prelude::*;
|
||||
use codec::{FullCodec, FullEncode, Encode, EncodeLike, Decode};
|
||||
use crate::hash::{Twox128, StorageHasher, ReversibleStorageHasher};
|
||||
use crate::{
|
||||
hash::{Twox128, StorageHasher, ReversibleStorageHasher},
|
||||
traits::Get,
|
||||
};
|
||||
use sp_runtime::generic::{Digest, DigestItem};
|
||||
pub use sp_runtime::TransactionOutcome;
|
||||
|
||||
pub mod unhashed;
|
||||
pub mod hashed;
|
||||
pub mod bounded_vec;
|
||||
pub mod child;
|
||||
#[doc(hidden)]
|
||||
pub mod generator;
|
||||
@@ -806,19 +810,21 @@ pub trait StorageDecodeLength: private::Sealed + codec::DecodeLength {
|
||||
/// outside of this crate.
|
||||
mod private {
|
||||
use super::*;
|
||||
use bounded_vec::{BoundedVecValue, BoundedVec};
|
||||
|
||||
pub trait Sealed {}
|
||||
|
||||
impl<T: Encode> Sealed for Vec<T> {}
|
||||
impl<Hash: Encode> Sealed for Digest<Hash> {}
|
||||
impl<T: BoundedVecValue, S: Get<u32>> Sealed for BoundedVec<T, S> {}
|
||||
}
|
||||
|
||||
impl<T: Encode> StorageAppend<T> for Vec<T> {}
|
||||
impl<T: Encode> StorageDecodeLength for Vec<T> {}
|
||||
|
||||
/// We abuse the fact that SCALE does not put any marker into the encoding, i.e.
|
||||
/// we only encode the internal vec and we can append to this vec. We have a test that ensures
|
||||
/// that if the `Digest` format ever changes, we need to remove this here.
|
||||
/// We abuse the fact that SCALE does not put any marker into the encoding, i.e. we only encode the
|
||||
/// internal vec and we can append to this vec. We have a test that ensures that if the `Digest`
|
||||
/// format ever changes, we need to remove this here.
|
||||
impl<Hash: Encode> StorageAppend<DigestItem<Hash>> for Digest<Hash> {}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user