Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin-Radecki committed Jan 2, 2025
1 parent 3abe30e commit b16b94e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions consensus/src/creation/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<H: Hasher> Creator<H> {
pub fn create_unit(&self, round: Round) -> Result<PreUnit<H>> {
let parents = match round.checked_sub(1) {
None => NodeMap::with_size(self.n_members),
Some(prev_round) => {
Some(prev_round) => {
let parents = self
.round_collectors
.get(usize::from(prev_round))
Expand All @@ -101,7 +101,7 @@ impl<H: Hasher> Creator<H> {
parents_with_rounds
}
};

Ok(PreUnit::new(
self.node_id,
round,
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ mod tests {
Hasher, NodeIndex, Round, Signed,
};
use aleph_bft_mock::{Data, Hasher64, Keychain, PartialMultisignature, Signature};
use codec::{Decode, Encode};
use aleph_bft_types::NodeMap;
use codec::{Decode, Encode};

fn test_unchecked_unit(
creator: NodeIndex,
Expand Down
6 changes: 5 additions & 1 deletion consensus/src/testing/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ impl UnitWithParents {
}

fn parent_hashes(&self) -> Vec<Hash64> {
self.parent_hashes.values().map(|(hash, _)| hash).cloned().collect()
self.parent_hashes
.values()
.map(|(hash, _)| hash)
.cloned()
.collect()
}
}

Expand Down
7 changes: 4 additions & 3 deletions consensus/src/units/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt::{Display, Formatter, Result as FmtResult};

use crate::{
Data, Hasher, Index, MultiKeychain, NodeCount, NodeIndex, NodeMap, Round,
SessionId, Signable, Signed, UncheckedSigned,
Data, Hasher, Index, MultiKeychain, NodeCount, NodeIndex, NodeMap, Round, SessionId, Signable,
Signed, UncheckedSigned,
};
use codec::{Decode, Encode};
use derivative::Derivative;
Expand Down Expand Up @@ -299,7 +299,8 @@ pub mod tests {

#[test]
fn test_control_hash_codec() {
let ch = ControlHash::<Hasher64>::new(&vec![Some(([0; 8], 2)), None, Some(([1; 8], 2))].into());
let ch =
ControlHash::<Hasher64>::new(&vec![Some(([0; 8], 2)), None, Some(([1; 8], 2))].into());
let encoded = ch.encode();
let decoded =
ControlHash::decode(&mut encoded.as_slice()).expect("should decode correctly");
Expand Down
5 changes: 4 additions & 1 deletion consensus/src/units/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ fn random_initial_reconstructed_units(
.collect()
}

fn parent_map<U: Unit<Hasher = Hasher64>>(parents: &Vec<U>, parent_round: Round) -> NodeMap<(Hash64, Round)> {
fn parent_map<U: Unit<Hasher = Hasher64>>(
parents: &Vec<U>,
parent_round: Round,
) -> NodeMap<(Hash64, Round)> {
let n_members = parents
.last()
.expect("there are parents")
Expand Down
6 changes: 5 additions & 1 deletion consensus/src/units/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ impl<K: Keychain> Validator<K> {
return Err(ValidationError::NotEnoughParents(pre_unit.clone()));
}
let control_hash = &pre_unit.control_hash();
if control_hash.parents_round_lookup.get(pre_unit.creator()).is_none() {
if control_hash
.parents_round_lookup
.get(pre_unit.creator())
.is_none()
{
return Err(ValidationError::NotDescendantOfPreviousUnit(
pre_unit.clone(),
));
Expand Down

0 comments on commit b16b94e

Please sign in to comment.