Skip to content

Commit

Permalink
history_tree.rs: fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg committed Jun 29, 2021
1 parent 824e05b commit 97c4110
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions zebra-chain/src/history_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
block::{Block, ChainHistoryMmrRootHash, Height},
orchard,
parameters::{Network, NetworkUpgrade},
primitives::zcash_history::{Entry, Tree},
primitives::zcash_history::{Entry, Tree as InnerHistoryTree},
sapling,
};

Expand All @@ -38,7 +38,7 @@ pub struct HistoryTree {
/// Merkle mountain range tree from `zcash_history`.
/// This is a "runtime" structure used to add / remove nodes, and it's not
/// persistent.
inner: Tree,
inner: InnerHistoryTree,
/// The number of nodes in the tree.
size: u32,
/// The peaks of the tree, indexed by their position in the array representation
Expand All @@ -50,7 +50,7 @@ pub struct HistoryTree {

impl HistoryTree {
/// Create a new history tree with a single block.
pub fn new_from_block(
pub fn from_block(
network: Network,
block: Arc<Block>,
sapling_root: &sapling::tree::Root,
Expand All @@ -60,8 +60,8 @@ impl HistoryTree {
.coinbase_height()
.expect("block must have coinbase height during contextual verification");
let network_upgrade = NetworkUpgrade::current(network, height);
// TODO: handle Orchard root
let (tree, entry) = Tree::new_from_block(network, block, sapling_root)?;
// TODO: handle Orchard root, see https://github.com/ZcashFoundation/zebra/issues/2283
let (tree, entry) = InnerHistoryTree::new_from_block(network, block, sapling_root)?;
let mut peaks = BTreeMap::new();
peaks.insert(0u32, entry);
Ok(HistoryTree {
Expand Down Expand Up @@ -208,7 +208,7 @@ impl HistoryTree {
// Remove all non-peak entries
self.peaks.retain(|k, _| peak_pos_set.contains(k));
// Rebuild tree
self.inner = Tree::new_from_cache(
self.inner = InnerHistoryTree::new_from_cache(
self.network,
self.network_upgrade,
self.size,
Expand All @@ -226,7 +226,7 @@ impl HistoryTree {

impl Clone for HistoryTree {
fn clone(&self) -> Self {
let tree = Tree::new_from_cache(
let tree = InnerHistoryTree::new_from_cache(
self.network,
self.network_upgrade,
self.size,
Expand Down

0 comments on commit 97c4110

Please sign in to comment.