extract out all primitives

This commit is contained in:
Robert Habermeier
2018-02-01 11:13:55 +01:00
parent a3b9c2af7d
commit 188332cc4b
17 changed files with 386 additions and 87 deletions
+22 -3
View File
@@ -16,9 +16,10 @@
//! Block and header type definitions.
use bytes;
use bytes::{self, Vec};
use hash::H256;
use parachain;
use transaction::UncheckedTransaction;
/// Used to refer to a block number.
pub type Number = u64;
@@ -33,6 +34,22 @@ pub type TransactionHash = H256;
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Log(#[serde(with="bytes")] pub Vec<u8>);
/// A Polkadot relay chain block.
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Block {
/// The block header.
pub header: Header,
/// All relay-chain transactions.
pub transactions: Vec<UncheckedTransaction>,
}
/// The digest of a block, useful for light-clients.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Digest {
/// All logs that have happened in the block.
pub logs: Vec<Log>,
}
/// A relay chain block header.
///
/// https://github.com/w3f/polkadot-spec/blob/master/spec.md#header
@@ -46,10 +63,12 @@ pub struct Header {
pub number: Number,
/// State root after this transition.
pub state_root: H256,
/// The root of the trie that represents this block's transactions, indexed by a 32-byte integer.
pub transaction_root: H256,
/// Parachain activity bitfield
pub parachain_activity: parachain::Activity,
/// Logs (generated by execution)
pub logs: Vec<Log>,
/// The digest of activity on the block.
pub digest: Digest,
}
/// A relay chain block body.