Compare digests item-by-item (#869)

* compare digest item-by-item

* update comment
This commit is contained in:
Svyatoslav Nikolsky
2018-10-05 15:16:22 +03:00
committed by Gav Wood
parent 4d18c50e67
commit 187c232629
3 changed files with 32 additions and 7 deletions
+19 -1
View File
@@ -333,6 +333,24 @@ impl CheckEqual for substrate_primitives::H256 {
}
}
impl<I> CheckEqual for I where I: DigestItem {
#[cfg(feature = "std")]
fn check_equal(&self, other: &Self) {
if self != other {
println!("DigestItem: given={:?}, expected={:?}", self, other);
}
}
#[cfg(not(feature = "std"))]
fn check_equal(&self, other: &Self) {
if self != other {
runtime_io::print("DigestItem not equal");
runtime_io::print(&Encode::encode(self)[..]);
runtime_io::print(&Encode::encode(other)[..]);
}
}
}
#[cfg(feature = "std")]
pub trait MaybeSerializeDebugButNotDeserialize: Serialize + Debug {}
#[cfg(feature = "std")]
@@ -491,7 +509,7 @@ pub trait Digest: Member + Default {
/// for casting member to 'system' log items, known to substrate.
///
/// If the runtime does not supports some 'system' items, use `()` as a stub.
pub trait DigestItem: Member {
pub trait DigestItem: Codec + Member {
type Hash: Member;
type AuthorityId: Member;