From 7b3ac3a22f5e08fe0d9022a70100f183b98fe9aa Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Tue, 13 Jul 2021 16:43:08 -0600 Subject: [PATCH] Lighten constraints on BridgeTree methods. --- src/bridgetree.rs | 56 ++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/bridgetree.rs b/src/bridgetree.rs index 00cb160..6af674d 100644 --- a/src/bridgetree.rs +++ b/src/bridgetree.rs @@ -694,6 +694,35 @@ pub enum BridgeTreeError { CheckpointMismatch, } +impl BridgeTree { + /// Removes the oldest checkpoint. Returns true if successful and false if + /// there are no checkpoints. + fn drop_oldest_checkpoint(&mut self) -> bool { + if self.checkpoints.is_empty() { + false + } else { + self.checkpoints.remove(0); + true + } + } + + pub fn bridges(&self) -> &Vec> { + &self.bridges + } + + pub fn witnessable_leaves(&self) -> &HashMap { + &self.saved + } + + pub fn checkpoints(&self) -> &Vec> { + &self.checkpoints + } + + pub fn max_checkpoints(&self) -> usize { + self.max_checkpoints + } +} + impl BridgeTree { pub fn new(max_checkpoints: usize) -> Self { BridgeTree { @@ -755,33 +784,6 @@ impl BridgeTree { }) } } - - /// Removes the oldest checkpoint. Returns true if successful and false if - /// there are no checkpoints. - fn drop_oldest_checkpoint(&mut self) -> bool { - if self.checkpoints.is_empty() { - false - } else { - self.checkpoints.remove(0); - true - } - } - - pub fn bridges(&self) -> &Vec> { - &self.bridges - } - - pub fn witnessable_leaves(&self) -> &HashMap { - &self.saved - } - - pub fn checkpoints(&self) -> &Vec> { - &self.checkpoints - } - - pub fn max_checkpoints(&self) -> usize { - self.max_checkpoints - } } impl crate::Frontier for BridgeTree {