Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 536bc57

Browse files
committed
MMR: impl TypeInfo for some structures
1 parent 25ea31f commit 536bc57

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

primitives/beefy/src/mmr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl BeefyDataProvider<Vec<u8>> for () {
4444
}
4545

4646
/// A standard leaf that gets added every block to the MMR constructed by Substrate's `pallet_mmr`.
47-
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
47+
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
4848
pub struct MmrLeaf<BlockNumber, Hash, MerkleRoot, ExtraData> {
4949
/// Version of the leaf format.
5050
///
@@ -73,7 +73,7 @@ pub struct MmrLeaf<BlockNumber, Hash, MerkleRoot, ExtraData> {
7373
/// Given that adding new struct elements in SCALE is backward compatible (i.e. old format can be
7474
/// still decoded, the new fields will simply be ignored). We expect the major version to be bumped
7575
/// very rarely (hopefuly never).
76-
#[derive(Debug, Default, PartialEq, Eq, Clone, Encode, Decode)]
76+
#[derive(Debug, Default, PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
7777
pub struct MmrLeafVersion(u8);
7878
impl MmrLeafVersion {
7979
/// Create new version object from `major` and `minor` components.

primitives/merkle-mountain-range/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1313

1414
[dependencies]
1515
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
16+
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
1617
log = { version = "0.4.17", default-features = false }
1718
serde = { version = "1.0.136", features = ["derive"], optional = true }
1819
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }

primitives/merkle-mountain-range/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![cfg_attr(not(feature = "std"), no_std)]
2121
#![warn(missing_docs)]
2222

23+
use scale_info::TypeInfo;
2324
use sp_debug_derive::RuntimeDebug;
2425
use sp_runtime::traits;
2526
#[cfg(not(feature = "std"))]
@@ -69,7 +70,7 @@ impl<Hash> OnNewRoot<Hash> for () {
6970
}
7071

7172
/// A MMR proof data for one of the leaves.
72-
#[derive(codec::Encode, codec::Decode, RuntimeDebug, Clone, PartialEq, Eq)]
73+
#[derive(codec::Encode, codec::Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
7374
pub struct Proof<Hash> {
7475
/// The index of the leaf the proof is for.
7576
pub leaf_index: LeafIndex,
@@ -352,7 +353,7 @@ impl_leaf_data_for_tuple!(A:0, B:1, C:2, D:3);
352353
impl_leaf_data_for_tuple!(A:0, B:1, C:2, D:3, E:4);
353354

354355
/// A MMR proof data for a group of leaves.
355-
#[derive(codec::Encode, codec::Decode, RuntimeDebug, Clone, PartialEq, Eq)]
356+
#[derive(codec::Encode, codec::Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
356357
pub struct BatchProof<Hash> {
357358
/// The indices of the leaves the proof is for.
358359
pub leaf_indices: Vec<LeafIndex>,

0 commit comments

Comments
 (0)