Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin-Radecki committed Dec 11, 2024
1 parent 34e096f commit dd5a112
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
28 changes: 17 additions & 11 deletions consensus/src/dag/reconstruction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::HashMap;
use aleph_bft_rmc::NodeCount;
use crate::{
units::{ControlHash, FullUnit, HashFor, Unit, UnitCoord, UnitWithParents, WrappedUnit},
Hasher, NodeMap, SessionId,
};
use aleph_bft_rmc::NodeCount;
use std::collections::HashMap;

mod dag;
mod parents;
Expand All @@ -27,15 +27,15 @@ impl<U: Unit> ReconstructedUnit<U> {
{
true => {
let unit_round = unit.round();
let mut parents_with_rounds = NodeMap::with_size(parents.size());
let mut parents_with_rounds = NodeMap::with_size(parents.size());
for (parent_index, hash) in parents.into_iter() {
parents_with_rounds.insert(parent_index, (hash, unit_round - 1));
}
Ok(ReconstructedUnit {
unit,
parents: parents_with_rounds,
unit,
parents: parents_with_rounds,
})
},
}
false => Err(unit),
}
}
Expand Down Expand Up @@ -87,12 +87,18 @@ impl<U: Unit> UnitWithParents for ReconstructedUnit<U> {
}

fn direct_parents(&self) -> impl Iterator<Item = &HashFor<Self>> {
self.parents.values().filter_map(|(hash, parent_round)| {
match self.unit.coord().round() {
self.parents
.values()
.filter_map(|(hash, parent_round)| match self.unit.coord().round() {
0 => None,
unit_round => if unit_round - 1 == *parent_round { Some(hash) } else { None },
}
})
unit_round => {
if unit_round - 1 == *parent_round {
Some(hash)
} else {
None
}
}
})
}

fn parent_for(&self, index: NodeIndex) -> Option<&HashFor<Self>> {
Expand Down
2 changes: 0 additions & 2 deletions consensus/src/units/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ pub trait UnitWithParents: Unit {
fn parents_size(&self) -> NodeCount;
}



impl<H: Hasher, D: Data> Unit for FullUnit<H, D> {
type Hasher = H;

Expand Down
2 changes: 1 addition & 1 deletion consensus/src/units/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pub fn minimal_reconstructed_dag_units_up_to(
.into_iterator()
.filter(|node_id| node_id != &inactive_node)
.map(|node_id| {
random_reconstructed_unit_with_parents(node_id, &parents, &keychains[node_id.0], r)
random_reconstructed_unit_with_parents(node_id, &parents, &keychains[node_id.0], r)
})
.collect();
dag.push(units);
Expand Down

0 comments on commit dd5a112

Please sign in to comment.