mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 22:21:07 +00:00
derive codec for inherent data (#2714)
* derive codec for inherent data * increase spec version
This commit is contained in:
@@ -53,7 +53,7 @@ pub use runtime_primitives::RuntimeString;
|
||||
pub type InherentIdentifier = [u8; 8];
|
||||
|
||||
/// Inherent data to include in a block.
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone, Default, Encode, Decode)]
|
||||
pub struct InherentData {
|
||||
/// All inherent data encoded with parity-codec and an identifier.
|
||||
data: BTreeMap<InherentIdentifier, Vec<u8>>
|
||||
@@ -123,33 +123,6 @@ impl InherentData {
|
||||
}
|
||||
}
|
||||
|
||||
impl codec::Encode for InherentData {
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
let keys = self.data.keys().collect::<Vec<_>>();
|
||||
let values = self.data.values().collect::<Vec<_>>();
|
||||
|
||||
let mut encoded = keys.encode();
|
||||
encoded.extend(values.encode());
|
||||
encoded
|
||||
}
|
||||
}
|
||||
|
||||
impl codec::Decode for InherentData {
|
||||
fn decode<I: codec::Input>(value: &mut I) -> Option<Self> {
|
||||
Vec::<InherentIdentifier>::decode(value)
|
||||
.and_then(|i| Vec::<Vec<u8>>::decode(value).map(|v| (i, v)))
|
||||
.and_then(|(i, v)| {
|
||||
if i.len() == v.len() {
|
||||
Some(Self {
|
||||
data: i.into_iter().zip(v.into_iter()).collect()
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// The result of checking inherents.
|
||||
///
|
||||
/// It either returns okay for all checks, stores all occurred errors or just one fatal error.
|
||||
|
||||
@@ -58,7 +58,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("node"),
|
||||
impl_name: create_runtime_str!("substrate-node"),
|
||||
authoring_version: 10,
|
||||
spec_version: 86,
|
||||
spec_version: 87,
|
||||
impl_version: 87,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user