Add new fns to ForkChoice and SlotClock

This commit is contained in:
Paul Hauner
2019-05-27 15:12:51 +10:00
parent 9922ed2239
commit 76602a65fc
11 changed files with 88 additions and 108 deletions

View File

@@ -21,8 +21,7 @@ pub mod longest_chain;
pub mod optimized_lmd_ghost;
pub mod slow_lmd_ghost;
// use store::stores::BeaconBlockAtSlotError;
// use store::DBError;
use std::sync::Arc;
use store::Error as DBError;
use types::{BeaconBlock, ChainSpec, Hash256};
@@ -34,7 +33,10 @@ pub use slow_lmd_ghost::SlowLMDGhost;
/// Defines the interface for Fork Choices. Each Fork choice will define their own data structures
/// which can be built in block processing through the `add_block` and `add_attestation` functions.
/// The main fork choice algorithm is specified in `find_head
pub trait ForkChoice: Send + Sync {
pub trait ForkChoice<T>: Send + Sync {
/// Create a new `ForkChoice` which reads from `store`.
fn new(store: Arc<T>) -> Self;
/// Called when a block has been added. Allows generic block-level data structures to be
/// built for a given fork-choice.
fn add_block(
@@ -78,22 +80,6 @@ impl From<DBError> for ForkChoiceError {
}
}
/*
impl From<BeaconBlockAtSlotError> for ForkChoiceError {
fn from(e: BeaconBlockAtSlotError) -> ForkChoiceError {
match e {
BeaconBlockAtSlotError::UnknownBeaconBlock(hash) => {
ForkChoiceError::MissingBeaconBlock(hash)
}
BeaconBlockAtSlotError::InvalidBeaconBlock(hash) => {
ForkChoiceError::MissingBeaconBlock(hash)
}
BeaconBlockAtSlotError::DBError(string) => ForkChoiceError::StorageError(string),
}
}
}
*/
/// Fork choice options that are currently implemented.
#[derive(Debug, Clone)]
pub enum ForkChoiceAlgorithm {