mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 12:51:05 +00:00
Update some types and interfaces to match the spec (#24)
* Update primitives. * Fix validator interface.
This commit is contained in:
committed by
Robert Habermeier
parent
d17dcc1893
commit
55e74cd426
@@ -16,25 +16,34 @@
|
||||
|
||||
//! Block and header type definitions.
|
||||
|
||||
use bytes;
|
||||
use hash::H256;
|
||||
use parachain;
|
||||
|
||||
/// Hash used to refer to a block hash.
|
||||
pub type HeaderHash = H256;
|
||||
|
||||
/// Execution log (event)
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Log(#[serde(with="bytes")] pub Vec<u8>);
|
||||
|
||||
/// A relay chain block header.
|
||||
///
|
||||
/// https://github.com/w3f/polkadot-spec/blob/master/spec.md#header
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Header {
|
||||
/// Block parent's hash.
|
||||
pub parent_hash: HeaderHash,
|
||||
/// State root after this transition.
|
||||
pub state_root: H256,
|
||||
/// Unix time at which this header was produced.
|
||||
pub timestamp: u64,
|
||||
/// Block number.
|
||||
pub number: u64,
|
||||
/// State root after this transition.
|
||||
pub state_root: H256,
|
||||
/// Parachain activity bitfield
|
||||
pub parachain_activity: parachain::Activity,
|
||||
/// Logs (generated by execution)
|
||||
pub logs: Vec<Log>,
|
||||
}
|
||||
|
||||
/// A relay chain block body.
|
||||
@@ -46,7 +55,7 @@ pub struct Header {
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Body {
|
||||
/// Parachain proposal blocks.
|
||||
pub para_blocks: Vec<parachain::Proposal>,
|
||||
pub candidates: Vec<parachain::Candidate>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -58,34 +67,17 @@ mod tests {
|
||||
fn test_header_serialization() {
|
||||
assert_eq!(ser::to_string_pretty(&Header {
|
||||
parent_hash: 5.into(),
|
||||
state_root: 3.into(),
|
||||
timestamp: 10,
|
||||
number: 67,
|
||||
state_root: 3.into(),
|
||||
parachain_activity: parachain::Activity(vec![0]),
|
||||
logs: vec![Log(vec![1])],
|
||||
}), r#"{
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000005",
|
||||
"number": 67,
|
||||
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000003",
|
||||
"timestamp": 10,
|
||||
"number": 67
|
||||
}"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_body_serialization() {
|
||||
assert_eq!(ser::to_string_pretty(&Body {
|
||||
para_blocks: vec![
|
||||
parachain::Proposal {
|
||||
parachain: 5.into(),
|
||||
header: parachain::Header(vec![1, 2, 3, 4]),
|
||||
proof_hash: 5.into(),
|
||||
}
|
||||
],
|
||||
}), r#"{
|
||||
"paraBlocks": [
|
||||
{
|
||||
"parachain": 5,
|
||||
"header": "0x01020304",
|
||||
"proofHash": "0x0000000000000000000000000000000000000000000000000000000000000005"
|
||||
}
|
||||
"parachainActivity": "0x00",
|
||||
"logs": [
|
||||
"0x01"
|
||||
]
|
||||
}"#);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user