parent
866acde6e8
commit
824f206dbe
|
|
@ -1,7 +1,7 @@
|
||||||
//! A binary hash tree of SHA256d (two rounds of SHA256) hashes for
|
//! A binary hash tree of SHA256d (two rounds of SHA256) hashes for
|
||||||
//! node values.
|
//! node values.
|
||||||
|
|
||||||
use std::io;
|
use std::{fmt, io};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use proptest_derive::Arbitrary;
|
use proptest_derive::Arbitrary;
|
||||||
|
|
@ -31,7 +31,7 @@ impl<Transaction> ZcashDeserialize for MerkleTree<Transaction> {
|
||||||
|
|
||||||
/// 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, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||||
#[cfg_attr(test, derive(Arbitrary))]
|
#[cfg_attr(test, derive(Arbitrary))]
|
||||||
pub struct MerkleTreeRootHash(pub [u8; 32]);
|
pub struct MerkleTreeRootHash(pub [u8; 32]);
|
||||||
|
|
||||||
|
|
@ -44,3 +44,11 @@ impl From<MerkleTree<Transaction>> for MerkleTreeRootHash {
|
||||||
Self(hash_writer.finish())
|
Self(hash_writer.finish())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for MerkleTreeRootHash {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_tuple("MerkleTreeRootHash")
|
||||||
|
.field(&hex::encode(&self.0))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@
|
||||||
//!
|
//!
|
||||||
//! A root of a note commitment tree is associated with each treestate.
|
//! A root of a note commitment tree is associated with each treestate.
|
||||||
|
|
||||||
use std::io;
|
use std::{fmt, io};
|
||||||
|
|
||||||
|
use hex;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use proptest_derive::Arbitrary;
|
use proptest_derive::Arbitrary;
|
||||||
|
|
@ -31,10 +33,18 @@ 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, Copy, Debug, Default, Eq, PartialEq)]
|
#[derive(Clone, Copy, Default, Eq, PartialEq)]
|
||||||
#[cfg_attr(test, derive(Arbitrary))]
|
#[cfg_attr(test, derive(Arbitrary))]
|
||||||
pub struct SaplingNoteTreeRootHash(pub [u8; 32]);
|
pub struct SaplingNoteTreeRootHash(pub [u8; 32]);
|
||||||
|
|
||||||
|
impl fmt::Debug for SaplingNoteTreeRootHash {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_tuple("SaplingNoteTreeRootHash")
|
||||||
|
.field(&hex::encode(&self.0))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<SaplingNoteCommitmentTree> for SaplingNoteTreeRootHash {
|
impl From<SaplingNoteCommitmentTree> for SaplingNoteTreeRootHash {
|
||||||
fn from(_tree: SaplingNoteCommitmentTree) -> Self {
|
fn from(_tree: SaplingNoteCommitmentTree) -> Self {
|
||||||
// TODO: The Sapling note commitment tree requires a Pedersen
|
// TODO: The Sapling note commitment tree requires a Pedersen
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,18 @@ impl Arbitrary for LockTime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An encoding of a Bitcoin script.
|
/// An encoding of a Bitcoin script.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Eq, PartialEq)]
|
||||||
#[cfg_attr(test, derive(Arbitrary))]
|
#[cfg_attr(test, derive(Arbitrary))]
|
||||||
pub struct Script(pub Vec<u8>);
|
pub struct Script(pub Vec<u8>);
|
||||||
|
|
||||||
|
impl fmt::Debug for Script {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_tuple("Script")
|
||||||
|
.field(&hex::encode(&self.0))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ZcashSerialize for Script {
|
impl ZcashSerialize for Script {
|
||||||
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
|
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
|
||||||
writer.write_compactsize(self.0.len() as u64)?;
|
writer.write_compactsize(self.0.len() as u64)?;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue