Derive Clone, Debug, Default, Eq, and PartialEq for new structs
This commit is contained in:
parent
38015c11a6
commit
c4547ea806
|
@ -13,6 +13,7 @@ use crate::transaction::Transaction;
|
||||||
///
|
///
|
||||||
/// This is useful when one block header is pointing to its parent
|
/// This is useful when one block header is pointing to its parent
|
||||||
/// block header in the block chain. ⛓️
|
/// block header in the block chain. ⛓️
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct BlockHeaderHash([u8; 32]);
|
pub struct BlockHeaderHash([u8; 32]);
|
||||||
|
|
||||||
impl From<BlockHeader> for BlockHeaderHash {
|
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
|
/// A SHA-256d hash of the root node of a merkle tree of SHA256-d
|
||||||
/// hashed transactions in a block.
|
/// hashed transactions in a block.
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct MerkleRootHash([u8; 32]);
|
pub struct MerkleRootHash([u8; 32]);
|
||||||
|
|
||||||
impl<Transaction> ZcashSerialize for MerkleTree<Transaction> {
|
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
|
/// backwards reference (previous header hash) present in the block
|
||||||
/// header. Each block points backwards to its parent, all the way
|
/// header. Each block points backwards to its parent, all the way
|
||||||
/// back to the genesis block (the first block in the blockchain).
|
/// back to the genesis block (the first block in the blockchain).
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct BlockHeader {
|
pub struct BlockHeader {
|
||||||
/// A SHA-256d hash in internal byte order of the previous block’s
|
/// A SHA-256d hash in internal byte order of the previous block’s
|
||||||
/// header. This ensures no previous block can be changed without
|
/// 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
|
/// [Sapling onward] The root LEBS2OSP256(rt) of the Sapling note
|
||||||
/// commitment tree corresponding to the finnal Sapling treestate of
|
/// commitment tree corresponding to the finnal Sapling treestate of
|
||||||
/// this block.
|
/// this block.
|
||||||
// TODO: replace type with custom SaplingRootHash or similar type
|
|
||||||
final_sapling_root_hash: SaplingNoteTreeRootHash,
|
final_sapling_root_hash: SaplingNoteTreeRootHash,
|
||||||
|
|
||||||
/// The block timestamp is a Unix epoch time (UTC) when the miner
|
/// 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
|
/// Block header: a data structure containing the block's metadata
|
||||||
/// Transactions: an array (vector in Rust) of transactions
|
/// Transactions: an array (vector in Rust) of transactions
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
/// First 80 bytes of the block as defined by the encoding used by
|
/// First 80 bytes of the block as defined by the encoding used by
|
||||||
/// "block" messages.
|
/// "block" messages.
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::sha256d_writer::Sha256dWriter;
|
||||||
// similar, it may be worth it to define a NoteCommitmentTree trait.
|
// similar, it may be worth it to define a NoteCommitmentTree trait.
|
||||||
|
|
||||||
/// Sapling Note Commitment Tree
|
/// Sapling Note Commitment Tree
|
||||||
#[derive(Default)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct SaplingNoteCommitmentTree;
|
pub struct SaplingNoteCommitmentTree;
|
||||||
|
|
||||||
/// Sapling note commitment tree root node hash.
|
/// Sapling note commitment tree root node hash.
|
||||||
|
@ -28,6 +28,7 @@ pub struct SaplingNoteCommitmentTree;
|
||||||
/// commitment tree corresponding to the final Sapling treestate of
|
/// commitment tree corresponding to the final Sapling treestate of
|
||||||
/// this block. A root of a note commitment tree is associated with
|
/// this block. A root of a note commitment tree is associated with
|
||||||
/// each treestate.
|
/// each treestate.
|
||||||
|
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct SaplingNoteTreeRootHash([u8; 32]);
|
pub struct SaplingNoteTreeRootHash([u8; 32]);
|
||||||
|
|
||||||
impl From<SaplingNoteCommitmentTree> for SaplingNoteTreeRootHash {
|
impl From<SaplingNoteCommitmentTree> for SaplingNoteTreeRootHash {
|
||||||
|
|
Loading…
Reference in New Issue