mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
Address majority of Michael's comments
This commit is contained in:
@@ -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