diff --git a/zcash_primitives/src/block.rs b/zcash_primitives/src/block.rs new file mode 100644 index 000000000..816975d0b --- /dev/null +++ b/zcash_primitives/src/block.rs @@ -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, +} + +impl BlockHeaderData { + pub fn freeze(self) -> BlockHeader { + BlockHeader(self) + } +} diff --git a/zcash_primitives/src/lib.rs b/zcash_primitives/src/lib.rs index 247520938..97b826f50 100644 --- a/zcash_primitives/src/lib.rs +++ b/zcash_primitives/src/lib.rs @@ -10,6 +10,7 @@ extern crate sapling_crypto; use sapling_crypto::jubjub::JubjubBls12; +pub mod block; pub mod sapling; mod serialize; pub mod transaction;