Skip to content

Commit

Permalink
Some more changes to naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin-Radecki committed Jan 7, 2025
1 parent c347236 commit d0a88f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ More details are available [in the book][reference-link-implementation-details].
- Import AlephBFT in your crate
```toml
[dependencies]
aleph-bft = "^0.40"
aleph-bft = "^0.41"
```
- The main entry point is the `run_session` function, which returns a Future that runs the
consensus algorithm.
Expand Down
5 changes: 1 addition & 4 deletions consensus/src/backup/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ impl<H: Hasher, D: Data, S: Signature, R: AsyncRead> BackupLoader<H, D, S, R> {
));
}

let parent_ids = &full_unit.as_pre_unit().control_hash().parents;

// Sanity check: verify that all unit's parents appeared in backup before it.
for (parent_id, round) in parent_ids.iter() {
let parent = UnitCoord::new(*round, parent_id);
for parent in full_unit.as_pre_unit().control_hash().parents() {
if !already_loaded_coords.contains(&parent) {
return Err(LoaderError::InconsistentData(coord));
}
Expand Down
16 changes: 7 additions & 9 deletions consensus/src/units/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,19 @@ pub struct ControlHash<H: Hasher> {
}

impl<H: Hasher> ControlHash<H> {
pub(crate) fn new(parents_round_lookup: &NodeMap<(H::Hash, Round)>) -> Self {
let mut parents_round_map = NodeMap::with_size(parents_round_lookup.size());
for (parent_index, (_, parent_round)) in parents_round_lookup.iter() {
parents_round_map.insert(parent_index, *parent_round);
pub(crate) fn new(parents_with_rounds_and_hashes: &NodeMap<(H::Hash, Round)>) -> Self {
let mut parents_with_rounds = NodeMap::with_size(parents_with_rounds_and_hashes.size());
for (parent_index, (_, parent_round)) in parents_with_rounds_and_hashes.iter() {
parents_with_rounds.insert(parent_index, *parent_round);
}
ControlHash {
parents: parents_round_map,
combined_hash: Self::create_control_hash(parents_round_lookup),
parents: parents_with_rounds,
combined_hash: Self::create_control_hash(parents_with_rounds_and_hashes),
}
}

/// Calculate parent control hash, which includes all parent hashes into account.
/// Calculate parent control hash, which includes all parent hashes and their rounds into account.
pub(crate) fn create_control_hash(parent_map: &NodeMap<(H::Hash, Round)>) -> H::Hash {
// we include parent rounds with calculating hash but this is okay - we cannot
// have two units with the same hash but different rounds
parent_map.using_encoded(H::hash)
}

Expand Down

0 comments on commit d0a88f9

Please sign in to comment.