Add comments to beacon chain fork choice
This commit is contained in:
parent
865919e398
commit
5ca53190b5
@ -56,6 +56,7 @@ where
|
|||||||
T: ClientDB,
|
T: ClientDB,
|
||||||
U: SlotClock,
|
U: SlotClock,
|
||||||
{
|
{
|
||||||
|
/// Instantiate a new Beacon Chain, from genesis.
|
||||||
pub fn genesis(
|
pub fn genesis(
|
||||||
state_store: Arc<BeaconStateStore<T>>,
|
state_store: Arc<BeaconStateStore<T>>,
|
||||||
block_store: Arc<BeaconBlockStore<T>>,
|
block_store: Arc<BeaconBlockStore<T>>,
|
||||||
|
@ -12,11 +12,6 @@ use types::{
|
|||||||
Hash256,
|
Hash256,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
|
||||||
pub enum Outcome {
|
|
||||||
Something,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
DBError(String),
|
DBError(String),
|
||||||
@ -32,6 +27,7 @@ where
|
|||||||
U: SlotClock,
|
U: SlotClock,
|
||||||
Error: From<<U as SlotClock>::Error>,
|
Error: From<<U as SlotClock>::Error>,
|
||||||
{
|
{
|
||||||
|
/// Run the fork-choice rule on the current chain, updating the canonical head, if required.
|
||||||
pub fn fork_choice(&self) -> Result<(), Error> {
|
pub fn fork_choice(&self) -> Result<(), Error> {
|
||||||
let present_head = &self.finalized_head().beacon_block_root;
|
let present_head = &self.finalized_head().beacon_block_root;
|
||||||
|
|
||||||
@ -56,6 +52,7 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A very inefficient implementation of LMD ghost.
|
||||||
pub fn slow_lmd_ghost(&self, start_hash: &Hash256) -> Result<Hash256, Error> {
|
pub fn slow_lmd_ghost(&self, start_hash: &Hash256) -> Result<Hash256, Error> {
|
||||||
let start = self
|
let start = self
|
||||||
.block_store
|
.block_store
|
||||||
@ -114,6 +111,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the total number of votes for some given block root.
|
||||||
|
///
|
||||||
|
/// The vote count is incrememented each time an attestation target votes for a block root.
|
||||||
fn get_vote_count<T: ClientDB>(
|
fn get_vote_count<T: ClientDB>(
|
||||||
block_store: &Arc<BeaconBlockStore<T>>,
|
block_store: &Arc<BeaconBlockStore<T>>,
|
||||||
attestation_targets: &[Hash256],
|
attestation_targets: &[Hash256],
|
||||||
|
Loading…
Reference in New Issue
Block a user