refactor: Make max_height call max_height_in_range

Closes #630.
This commit is contained in:
teor 2020-07-10 16:29:47 +10:00 committed by Henry de Valence
parent 78459afe97
commit e58c913897
1 changed files with 2 additions and 7 deletions

View File

@ -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")
}