From e58c913897037feeda3c381d09638a5cbcfbba76 Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 10 Jul 2020 16:29:47 +1000 Subject: [PATCH] refactor: Make max_height call max_height_in_range Closes #630. --- zebra-consensus/src/checkpoint/list.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/zebra-consensus/src/checkpoint/list.rs b/zebra-consensus/src/checkpoint/list.rs index 2a8c4897..f537f0a8 100644 --- a/zebra-consensus/src/checkpoint/list.rs +++ b/zebra-consensus/src/checkpoint/list.rs @@ -67,7 +67,7 @@ impl CheckpointList { Ok(CheckpointList(checkpoints)) } - /// Is there a checkpoint at `height`? + /// Return true if there a checkpoint at `height`. /// /// See `BTreeMap::contains_key()` for details. pub fn contains(&self, height: BlockHeight) -> bool { @@ -86,13 +86,8 @@ impl CheckpointList { /// /// If there is only a single checkpoint, then the maximum height will be /// zero. (The genesis block.) - /// - /// The maximum height is constant for each checkpoint list. pub fn max_height(&self) -> BlockHeight { - self.0 - .keys() - .cloned() - .next_back() + self.max_height_in_range(..) .expect("checkpoint lists must have at least one checkpoint") }