Add `BridgeTree::from_frontier`

Add a constructor to allow a BridgeTree to be built starting at an
existing frontier.
This commit is contained in:
Kris Nuttycombe 2022-03-31 11:35:46 -06:00
parent 279331e4f3
commit f19cf9c381
1 changed files with 12 additions and 0 deletions

View File

@ -762,6 +762,18 @@ impl<H: Hashable + Ord + Clone, const DEPTH: u8> BridgeTree<H, DEPTH> {
}
}
/// Construct a new BridgeTree that will start recording changes from the state of
/// the specified frontier.
pub fn from_frontier(max_checkpoints: usize, frontier: NonEmptyFrontier<H>) -> Self {
Self {
prior_bridges: vec![],
current_bridge: Some(MerkleBridge::from_parts(None, BTreeMap::new(), frontier)),
saved: BTreeMap::new(),
checkpoints: vec![],
max_checkpoints,
}
}
pub fn from_parts(
prior_bridges: Vec<MerkleBridge<H>>,
current_bridge: Option<MerkleBridge<H>>,