From ce1e81b27478b3ccfe3fab7aa925f62264189c3d Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Sat, 15 Aug 2020 20:57:59 -0700 Subject: [PATCH] chain: move merkle_tree to block::merkle. This Merkle tree is the SHA256d one used only for including transactions in a block, so it should be kept there in order to not be confused with other Merkle trees (like the note commitment trees). --- zebra-chain/src/block.rs | 2 ++ zebra-chain/src/block/header.rs | 3 +-- zebra-chain/src/{merkle_tree.rs => block/merkle.rs} | 0 zebra-chain/src/block/serialize.rs | 2 +- zebra-chain/src/block/tests/arbitrary.rs | 3 +-- zebra-chain/src/lib.rs | 2 -- 6 files changed, 5 insertions(+), 7 deletions(-) rename zebra-chain/src/{merkle_tree.rs => block/merkle.rs} (100%) diff --git a/zebra-chain/src/block.rs b/zebra-chain/src/block.rs index d689d966..e97858ba 100644 --- a/zebra-chain/src/block.rs +++ b/zebra-chain/src/block.rs @@ -10,6 +10,8 @@ mod height; mod root_hash; mod serialize; +pub mod merkle; + #[cfg(test)] mod tests; diff --git a/zebra-chain/src/block/header.rs b/zebra-chain/src/block/header.rs index a998299e..cd730115 100644 --- a/zebra-chain/src/block/header.rs +++ b/zebra-chain/src/block/header.rs @@ -1,10 +1,9 @@ use chrono::{DateTime, Duration, Utc}; -use crate::merkle_tree::MerkleTreeRootHash; use crate::serialization::ZcashSerialize; use crate::work::{difficulty::CompactDifficulty, equihash::Solution}; -use super::{BlockHeaderHash, Error}; +use super::{merkle::MerkleTreeRootHash, BlockHeaderHash, Error}; /// Block header. /// diff --git a/zebra-chain/src/merkle_tree.rs b/zebra-chain/src/block/merkle.rs similarity index 100% rename from zebra-chain/src/merkle_tree.rs rename to zebra-chain/src/block/merkle.rs diff --git a/zebra-chain/src/block/serialize.rs b/zebra-chain/src/block/serialize.rs index 4076df91..099f0d95 100644 --- a/zebra-chain/src/block/serialize.rs +++ b/zebra-chain/src/block/serialize.rs @@ -2,11 +2,11 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use chrono::{TimeZone, Utc}; use std::io; -use crate::merkle_tree::MerkleTreeRootHash; use crate::serialization::ZcashDeserializeInto; use crate::serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize}; use crate::work::{difficulty::CompactDifficulty, equihash}; +use super::merkle::MerkleTreeRootHash; use super::Block; use super::BlockHeader; use super::BlockHeaderHash; diff --git a/zebra-chain/src/block/tests/arbitrary.rs b/zebra-chain/src/block/tests/arbitrary.rs index 73abc0e7..fd5ae8b6 100644 --- a/zebra-chain/src/block/tests/arbitrary.rs +++ b/zebra-chain/src/block/tests/arbitrary.rs @@ -1,4 +1,3 @@ -use crate::merkle_tree::MerkleTreeRootHash; use crate::parameters::Network; use crate::work::{difficulty::CompactDifficulty, equihash}; @@ -32,7 +31,7 @@ impl Arbitrary for BlockHeader { // version is interpreted as i32 in the spec, so we are limited to i32::MAX here (4u32..(i32::MAX as u32)), any::(), - any::(), + any::(), any::<[u8; 32]>(), // time is interpreted as u32 in the spec, but rust timestamps are i64 (0i64..(u32::MAX as i64)), diff --git a/zebra-chain/src/lib.rs b/zebra-chain/src/lib.rs index 51e876d4..fc873395 100644 --- a/zebra-chain/src/lib.rs +++ b/zebra-chain/src/lib.rs @@ -11,8 +11,6 @@ #[macro_use] extern crate serde; -mod merkle_tree; - pub mod amount; pub mod block; pub mod parameters;