Replace Target<block::Height> with TargetHeight (#1289)

We don't use this generic, so let's just remove it.
This commit is contained in:
teor 2020-11-13 10:11:25 +10:00 committed by GitHub
parent 4e07719a7d
commit af4797130b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -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<block::Height> {
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

View File

@ -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};

View File

@ -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<block::Height> {
}
}
/// 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<HeightOrHash> {
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<HeightOrHash> {
/// Block height target, in chain order.
///
/// `WaitingForBlocks` is incomparable with itself and `Checkpoint(_)`.
impl PartialOrd for Target<block::Height> {
impl PartialOrd for TargetHeight {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
// FinishedVerifying is the final state