mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
Address majority of Michael's comments
This commit is contained in:
@@ -65,7 +65,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
||||
Self {
|
||||
backend,
|
||||
genesis_block_root,
|
||||
checkpoint_manager: RwLock::new(CheckpointManager::new(genesis_checkpoint.clone())),
|
||||
checkpoint_manager: RwLock::new(CheckpointManager::new(genesis_checkpoint)),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,10 +248,9 @@ impl CheckpointManager {
|
||||
finalized: state.finalized_checkpoint.clone(),
|
||||
};
|
||||
|
||||
// From the given state, read the block root at first slot of
|
||||
// `self.justified_checkpoint.epoch`. If that root matches, then
|
||||
// `new_justified_checkpoint` is a descendant of `self.justified_checkpoint` and we may
|
||||
// proceed (see next `if` statement).
|
||||
// Using the given `state`, determine its ancestor at the slot of our current justified
|
||||
// epoch. Later, this will be compared to the root of the current justified checkpoint
|
||||
// to determine if this state is descendant of our current justified state.
|
||||
let new_checkpoint_ancestor = Self::get_block_root_at_slot(
|
||||
state,
|
||||
chain,
|
||||
|
||||
@@ -34,12 +34,12 @@ impl ProtoArray {
|
||||
/// the best-child of each parent.
|
||||
///
|
||||
/// The structure of the `self.nodes` array ensures that the child of each node is always
|
||||
/// touched before it's parent.
|
||||
/// touched before its parent.
|
||||
///
|
||||
/// For each node, the following is done:
|
||||
///
|
||||
/// - Update the nodes weight with the corresponding delta.
|
||||
/// - Back-propgrate each nodes delta to its parents delta.
|
||||
/// - Update the node's weight with the corresponding delta.
|
||||
/// - Back-propagate each node's delta to its parents delta.
|
||||
/// - Compare the current node with the parents best-child, updating it if the current node
|
||||
/// should become the best child.
|
||||
/// - If required, update the parents best-descendant with the current node or its best-descendant.
|
||||
@@ -63,7 +63,7 @@ impl ProtoArray {
|
||||
|
||||
// Iterate backwards through all indices in `self.nodes`.
|
||||
for node_index in (0..self.nodes.len()).rev() {
|
||||
let node = &mut self
|
||||
let node = self
|
||||
.nodes
|
||||
.get_mut(node_index)
|
||||
.ok_or_else(|| Error::InvalidNodeIndex(node_index))?;
|
||||
@@ -108,7 +108,7 @@ impl ProtoArray {
|
||||
.get_mut(parent_index)
|
||||
.ok_or_else(|| Error::InvalidParentDelta(parent_index))?;
|
||||
|
||||
// Back-propogate the nodes delta to its parent.
|
||||
// Back-propagate the nodes delta to its parent.
|
||||
*parent_delta += node_delta;
|
||||
|
||||
self.maybe_update_best_child_and_descendant(parent_index, node_index)?;
|
||||
|
||||
@@ -261,7 +261,7 @@ fn compute_deltas(
|
||||
// of our tree (i.e., pre-finalization) and therefore not interesting.
|
||||
if let Some(current_delta_index) = indices.get(&vote.current_root).copied() {
|
||||
let delta = deltas
|
||||
.get_mut(current_delta_index)
|
||||
.get(current_delta_index)
|
||||
.ok_or_else(|| Error::InvalidNodeDelta(current_delta_index))?
|
||||
.checked_sub(old_balance as i64)
|
||||
.ok_or_else(|| Error::DeltaOverflow(current_delta_index))?;
|
||||
|
||||
Reference in New Issue
Block a user