Update original lmd-ghost begin intergration.

This commit is contained in:
Age Manning
2019-02-13 14:49:57 +11:00
parent ef1717312f
commit c4c1e5647e
6 changed files with 231 additions and 9 deletions

View File

@@ -23,12 +23,13 @@ pub mod optimised_lmd_ghost;
pub mod protolambda_lmd_ghost;
pub mod slow_lmd_ghost;
use db::stores::BeaconBlockAtSlotError;
use db::DBError;
use types::{BeaconBlock, Hash256};
/// 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`.
/// The main fork choice algorithm is specified in `find_head
pub trait ForkChoice {
/// Called when a block has been added. Allows generic block-level data structures to be
/// built for a given fork-choice.
@@ -66,6 +67,20 @@ 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.
pub enum ForkChoiceAlgorithms {
/// Chooses the longest chain becomes the head. Not for production.