mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Update SlowLMDGhost to use SlotHeight.
This commit is contained in:
@@ -30,10 +30,8 @@ use fast_math::log2_raw;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use types::{
|
use types::{
|
||||||
readers::BeaconBlockReader,
|
readers::BeaconBlockReader, slot_epoch::Slot, slot_height::SlotHeight,
|
||||||
slot_epoch_height::{Height, Slot},
|
validator_registry::get_active_validator_indices, BeaconBlock, Hash256,
|
||||||
validator_registry::get_active_validator_indices,
|
|
||||||
BeaconBlock, Hash256,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO: Pruning - Children
|
//TODO: Pruning - Children
|
||||||
@@ -77,7 +75,7 @@ pub struct OptimisedLMDGhost<T: ClientDB + Sized> {
|
|||||||
block_store: Arc<BeaconBlockStore<T>>,
|
block_store: Arc<BeaconBlockStore<T>>,
|
||||||
/// State storage access.
|
/// State storage access.
|
||||||
state_store: Arc<BeaconStateStore<T>>,
|
state_store: Arc<BeaconStateStore<T>>,
|
||||||
max_known_height: Height,
|
max_known_height: SlotHeight,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> OptimisedLMDGhost<T>
|
impl<T> OptimisedLMDGhost<T>
|
||||||
@@ -93,7 +91,7 @@ where
|
|||||||
ancestors: vec![HashMap::new(); 16],
|
ancestors: vec![HashMap::new(); 16],
|
||||||
latest_attestation_targets: HashMap::new(),
|
latest_attestation_targets: HashMap::new(),
|
||||||
children: HashMap::new(),
|
children: HashMap::new(),
|
||||||
max_known_height: Height::new(0),
|
max_known_height: SlotHeight::new(0),
|
||||||
block_store,
|
block_store,
|
||||||
state_store,
|
state_store,
|
||||||
}
|
}
|
||||||
@@ -118,7 +116,7 @@ where
|
|||||||
.ok_or_else(|| ForkChoiceError::MissingBeaconState(*state_root))?;
|
.ok_or_else(|| ForkChoiceError::MissingBeaconState(*state_root))?;
|
||||||
|
|
||||||
let active_validator_indices = get_active_validator_indices(
|
let active_validator_indices = get_active_validator_indices(
|
||||||
¤t_state.validator_registry,
|
¤t_state.validator_registry[..],
|
||||||
block_slot.epoch(EPOCH_LENGTH),
|
block_slot.epoch(EPOCH_LENGTH),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -137,7 +135,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the ancestor at a given height `at_height` of a block specified by `block_hash`.
|
/// Gets the ancestor at a given height `at_height` of a block specified by `block_hash`.
|
||||||
fn get_ancestor(&mut self, block_hash: Hash256, at_height: Height) -> Option<Hash256> {
|
fn get_ancestor(&mut self, block_hash: Hash256, at_height: SlotHeight) -> Option<Hash256> {
|
||||||
// return None if we can't get the block from the db.
|
// return None if we can't get the block from the db.
|
||||||
let block_height = {
|
let block_height = {
|
||||||
let block_slot = self
|
let block_slot = self
|
||||||
@@ -186,7 +184,7 @@ where
|
|||||||
fn get_clear_winner(
|
fn get_clear_winner(
|
||||||
&mut self,
|
&mut self,
|
||||||
latest_votes: &HashMap<Hash256, u64>,
|
latest_votes: &HashMap<Hash256, u64>,
|
||||||
block_height: Height,
|
block_height: SlotHeight,
|
||||||
) -> Option<Hash256> {
|
) -> Option<Hash256> {
|
||||||
// map of vote counts for every hash at this height
|
// map of vote counts for every hash at this height
|
||||||
let mut current_votes: HashMap<Hash256, u64> = HashMap::new();
|
let mut current_votes: HashMap<Hash256, u64> = HashMap::new();
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ use db::{
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use types::{
|
use types::{
|
||||||
readers::{BeaconBlockReader, BeaconStateReader},
|
readers::BeaconBlockReader, slot_epoch::Slot, validator_registry::get_active_validator_indices,
|
||||||
slot_epoch_height::Slot,
|
|
||||||
validator_registry::get_active_validator_indices,
|
|
||||||
BeaconBlock, Hash256,
|
BeaconBlock, Hash256,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user