Block header representation

This commit is contained in:
Jack Grigg 2018-10-11 23:14:46 +01:00
parent e4187f07ff
commit e21be37042
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
use std::ops::Deref;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct BlockHash(pub [u8; 32]);
/// A Zcash block header.
pub struct BlockHeader(BlockHeaderData);
impl Deref for BlockHeader {
type Target = BlockHeaderData;
fn deref(&self) -> &BlockHeaderData {
&self.0
}
}
pub struct BlockHeaderData {
pub version: i32,
pub prev_block: BlockHash,
pub merkle_root: [u8; 32],
pub final_sapling_root: [u8; 32],
pub time: u32,
pub bits: u32,
pub nonce: [u8; 32],
pub solution: Vec<u8>,
}
impl BlockHeaderData {
pub fn freeze(self) -> BlockHeader {
BlockHeader(self)
}
}

View File

@ -10,6 +10,7 @@ extern crate sapling_crypto;
use sapling_crypto::jubjub::JubjubBls12;
pub mod block;
pub mod sapling;
mod serialize;
pub mod transaction;