Add BeaconBlockHeader type.

This commit is contained in:
Paul Hauner 2019-03-15 15:40:28 +11:00
parent 2295322e3c
commit d84850b892
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,38 @@
use crate::test_utils::TestRandom;
use crate::*;
use bls::Signature;
use rand::RngCore;
use serde_derive::{Deserialize, Serialize};
use ssz::TreeHash;
use ssz_derive::{Decode, Encode, SignedRoot, TreeHash};
use test_random_derive::TestRandom;
/// A header of a `BeaconBlock`.
///
/// Spec v0.5.0
#[derive(
Debug,
PartialEq,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
SignedRoot,
)]
pub struct BeaconBlockHeader {
pub slot: Slot,
pub previous_block_root: Hash256,
pub state_root: Hash256,
pub block_body_root: Hash256,
pub signature: Signature,
}
#[cfg(test)]
mod tests {
use super::*;
ssz_tests!(BeaconBlockHeader);
}

View File

@ -9,6 +9,7 @@ pub mod attestation_data_and_custody_bit;
pub mod attester_slashing;
pub mod beacon_block;
pub mod beacon_block_body;
pub mod beacon_block_header;
pub mod beacon_state;
pub mod chain_spec;
pub mod crosslink;
@ -43,6 +44,7 @@ pub use crate::attestation_data_and_custody_bit::AttestationDataAndCustodyBit;
pub use crate::attester_slashing::AttesterSlashing;
pub use crate::beacon_block::BeaconBlock;
pub use crate::beacon_block_body::BeaconBlockBody;
pub use crate::beacon_block_header::BeaconBlockHeader;
pub use crate::beacon_state::{BeaconState, Error as BeaconStateError, RelativeEpoch};
pub use crate::chain_spec::{ChainSpec, Domain};
pub use crate::crosslink::Crosslink;