From af4797130b7770bfde58c784debe28b810aad04e Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 13 Nov 2020 10:11:25 +1000 Subject: [PATCH] Replace Target with TargetHeight (#1289) We don't use this generic, so let's just remove it. --- zebra-consensus/src/checkpoint.rs | 4 ++-- zebra-consensus/src/checkpoint/tests.rs | 2 +- zebra-consensus/src/checkpoint/types.rs | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/zebra-consensus/src/checkpoint.rs b/zebra-consensus/src/checkpoint.rs index 4e1b8e82..c9a407ef 100644 --- a/zebra-consensus/src/checkpoint.rs +++ b/zebra-consensus/src/checkpoint.rs @@ -44,7 +44,7 @@ mod tests; pub(crate) use list::CheckpointList; use types::{Progress, Progress::*}; -use types::{Target, Target::*}; +use types::{TargetHeight, TargetHeight::*}; /// An unverified block, which is in the queue for checkpoint verification. #[derive(Debug)] @@ -262,7 +262,7 @@ where /// `height` increases as checkpoints are verified. /// /// If verification has finished, returns `FinishedVerifying`. - fn target_checkpoint_height(&self) -> Target { + fn target_checkpoint_height(&self) -> TargetHeight { // Find the height we want to start searching at let start_height = match self.previous_checkpoint_height() { // Check if we have the genesis block as a special case, to simplify the loop diff --git a/zebra-consensus/src/checkpoint/tests.rs b/zebra-consensus/src/checkpoint/tests.rs index 6f2c99d8..4b8eb803 100644 --- a/zebra-consensus/src/checkpoint/tests.rs +++ b/zebra-consensus/src/checkpoint/tests.rs @@ -3,7 +3,7 @@ use super::*; use super::types::Progress::*; -use super::types::Target::*; +use super::types::TargetHeight::*; use color_eyre::eyre::{eyre, Report}; use futures::{future::TryFutureExt, stream::FuturesUnordered}; diff --git a/zebra-consensus/src/checkpoint/types.rs b/zebra-consensus/src/checkpoint/types.rs index 6ca0dcac..db295d92 100644 --- a/zebra-consensus/src/checkpoint/types.rs +++ b/zebra-consensus/src/checkpoint/types.rs @@ -5,7 +5,7 @@ use std::cmp::Ordering; use zebra_chain::block; use Progress::*; -use Target::*; +use TargetHeight::*; /// A `CheckpointVerifier`'s current progress verifying the chain. #[derive(Clone, Copy, Debug, Eq, PartialEq)] @@ -62,16 +62,17 @@ impl PartialOrd for Progress { } } -/// A `CheckpointVerifier`'s target checkpoint, based on the current queue. +/// A `CheckpointVerifier`'s target checkpoint height, based on the current +/// queue. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum Target { +pub enum TargetHeight { /// We need more blocks before we can choose a target checkpoint. WaitingForBlocks, /// We want to verify this checkpoint. /// /// The target checkpoint can be multiple checkpoints ahead of the previous /// checkpoint. - Checkpoint(HeightOrHash), + Checkpoint(block::Height), /// We have finished verifying, there will be no more targets. FinishedVerifying, } @@ -79,7 +80,7 @@ pub enum Target { /// Block height target, in chain order. /// /// `WaitingForBlocks` is incomparable with itself and `Checkpoint(_)`. -impl PartialOrd for Target { +impl PartialOrd for TargetHeight { fn partial_cmp(&self, other: &Self) -> Option { match (self, other) { // FinishedVerifying is the final state