Derive Clone, Debug, Default, Eq, and PartialEq for new structs

This commit is contained in:
Deirdre Connolly 2019-09-26 02:28:58 -04:00 committed by Deirdre Connolly
parent 38015c11a6
commit c4547ea806
2 changed files with 6 additions and 2 deletions

View File

@ -13,6 +13,7 @@ use crate::transaction::Transaction;
///
/// This is useful when one block header is pointing to its parent
/// block header in the block chain. ⛓️
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BlockHeaderHash([u8; 32]);
impl From<BlockHeader> for BlockHeaderHash {
@ -27,6 +28,7 @@ impl From<BlockHeader> for BlockHeaderHash {
/// A SHA-256d hash of the root node of a merkle tree of SHA256-d
/// hashed transactions in a block.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MerkleRootHash([u8; 32]);
impl<Transaction> ZcashSerialize for MerkleTree<Transaction> {
@ -57,6 +59,7 @@ impl From<MerkleTree<Transaction>> for MerkleRootHash {
/// backwards reference (previous header hash) present in the block
/// header. Each block points backwards to its parent, all the way
/// back to the genesis block (the first block in the blockchain).
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BlockHeader {
/// A SHA-256d hash in internal byte order of the previous blocks
/// header. This ensures no previous block can be changed without
@ -80,7 +83,6 @@ pub struct BlockHeader {
/// [Sapling onward] The root LEBS2OSP256(rt) of the Sapling note
/// commitment tree corresponding to the finnal Sapling treestate of
/// this block.
// TODO: replace type with custom SaplingRootHash or similar type
final_sapling_root_hash: SaplingNoteTreeRootHash,
/// The block timestamp is a Unix epoch time (UTC) when the miner
@ -134,6 +136,7 @@ impl ZcashDeserialize for BlockHeader {
///
/// Block header: a data structure containing the block's metadata
/// Transactions: an array (vector in Rust) of transactions
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Block {
/// First 80 bytes of the block as defined by the encoding used by
/// "block" messages.

View File

@ -19,7 +19,7 @@ use crate::sha256d_writer::Sha256dWriter;
// similar, it may be worth it to define a NoteCommitmentTree trait.
/// Sapling Note Commitment Tree
#[derive(Default)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct SaplingNoteCommitmentTree;
/// Sapling note commitment tree root node hash.
@ -28,6 +28,7 @@ pub struct SaplingNoteCommitmentTree;
/// commitment tree corresponding to the final Sapling treestate of
/// this block. A root of a note commitment tree is associated with
/// each treestate.
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct SaplingNoteTreeRootHash([u8; 32]);
impl From<SaplingNoteCommitmentTree> for SaplingNoteTreeRootHash {