mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 07:37:57 +00:00
Make Digest support StorageAppend (#5922)
* Make `Digest` support `StorageAppend` This adds support for `StorageAppend` to `Digest`. Digest is just a wrapper around a `Vec` and we abuse the fact that SCALE does not puts any special marker into the encoding for structs. So, we can just append to the encoded Digest. A test is added that ensures, if the `Digest` format ever changes, we remove this optimization. * Update weight * Update frame/support/src/storage/mod.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Update frame/system/src/lib.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
@@ -28,18 +28,22 @@ use sp_core::{ChangesTrieConfiguration, RuntimeDebug};
|
||||
/// Generic header digest.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, parity_util_mem::MallocSizeOf))]
|
||||
pub struct Digest<Hash: Encode + Decode> {
|
||||
pub struct Digest<Hash> {
|
||||
/// A list of logs in the digest.
|
||||
#[cfg_attr(
|
||||
feature = "std",
|
||||
serde(bound(serialize = "Hash: codec::Codec", deserialize = "Hash: codec::Codec"))
|
||||
)]
|
||||
pub logs: Vec<DigestItem<Hash>>,
|
||||
}
|
||||
|
||||
impl<Item: Encode + Decode> Default for Digest<Item> {
|
||||
impl<Item> Default for Digest<Item> {
|
||||
fn default() -> Self {
|
||||
Digest { logs: Vec::new(), }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Hash: Encode + Decode> Digest<Hash> {
|
||||
impl<Hash> Digest<Hash> {
|
||||
/// Get reference to all digest items.
|
||||
pub fn logs(&self) -> &[DigestItem<Hash>] {
|
||||
&self.logs
|
||||
|
||||
Reference in New Issue
Block a user