Skip to content

Commit

Permalink
return the round of a unit with the unit data when the unit is finalized
Browse files Browse the repository at this point in the history
  • Loading branch information
joschisan committed Nov 25, 2023
1 parent c61c91f commit 5267b5b
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 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.33"
aleph-bft = "^0.34"
```
- The main entry point is the `run_session` function, which returns a Future that runs the
consensus algorithm.
Expand Down
4 changes: 2 additions & 2 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft"
version = "0.33.0"
version = "0.34.0"
edition = "2021"
authors = ["Cardinal Cryptography"]
categories = ["algorithms", "data-structures", "cryptography", "database"]
Expand All @@ -14,7 +14,7 @@ description = "AlephBFT is an asynchronous and Byzantine fault tolerant consensu

[dependencies]
aleph-bft-rmc = { path = "../rmc", version = "0.11" }
aleph-bft-types = { path = "../types", version = "0.11" }
aleph-bft-types = { path = "../types", version = "0.12" }
anyhow = "1.0"
async-trait = "0.1"
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/runway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,13 +664,13 @@ where
.expect("Ordered units must be in store")
.as_signable();

(unit.data().clone(), unit.creator())
(unit.data().clone(), unit.creator(), unit.round())
})
.collect();

for (d, creator) in data_iter {
for (d, creator, round) in data_iter {
if let Some(d) = d {
self.finalization_handler.data_finalized(d, creator);
self.finalization_handler.data_finalized(d, creator, round);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/aleph_bft_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The FinalizationHandler trait is an abstraction for a component that should hand

```rust
pub trait FinalizationHandler<Data> {
fn data_finalized(&mut self, data: Data, creator: NodeIndex);
fn data_finalized(&mut self, data: Data, creator: NodeIndex, round: Round);
}
```

Expand Down
4 changes: 2 additions & 2 deletions examples/ordering/src/dataio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aleph_bft_types::{
DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex,
DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, Round,
};
use async_trait::async_trait;
use codec::{Decode, Encode};
Expand Down Expand Up @@ -56,7 +56,7 @@ pub struct FinalizationHandler {
}

impl FinalizationHandlerT<Data> for FinalizationHandler {
fn data_finalized(&mut self, d: Data, _creator: NodeIndex) {
fn data_finalized(&mut self, d: Data, _creator: NodeIndex, _round: Round) {
if let Err(e) = self.tx.unbounded_send(d) {
error!(target: "finalization-handler", "Error when sending data from FinalizationHandler {:?}.", e);
}
Expand Down
4 changes: 2 additions & 2 deletions mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft-mock"
version = "0.11.1"
version = "0.12.0"
edition = "2021"
authors = ["Cardinal Cryptography"]
documentation = "https://docs.rs/?"
Expand All @@ -11,7 +11,7 @@ readme = "./README.md"
description = "Mock implementations of traits required by the aleph-bft package. Do NOT use outside of testing!"

[dependencies]
aleph-bft-types = { path = "../types", version = "0.11" }
aleph-bft-types = { path = "../types", version = "0.12" }
async-trait = "0.1"
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
futures = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions mock/src/dataio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aleph_bft_types::{
DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex,
DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, Round,
};
use async_trait::async_trait;
use codec::{Decode, Encode};
Expand Down Expand Up @@ -73,7 +73,7 @@ pub struct FinalizationHandler {
}

impl FinalizationHandlerT<Data> for FinalizationHandler {
fn data_finalized(&mut self, d: Data, _creator: NodeIndex) {
fn data_finalized(&mut self, d: Data, _creator: NodeIndex, _round: Round) {
if let Err(e) = self.tx.unbounded_send(d) {
error!(target: "finalization-handler", "Error when sending data from FinalizationHandler {:?}.", e);
}
Expand Down
2 changes: 1 addition & 1 deletion rmc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description = "Reliable MultiCast - a primitive for Reliable Broadcast protocol.

[dependencies]
aleph-bft-crypto = { path = "../crypto", version = "0.8" }
aleph-bft-types = { path = "../types", version = "0.11" }
aleph-bft-types = { path = "../types", version = "0.12" }
async-trait = "0.1"
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
futures = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft-types"
version = "0.11.0"
version = "0.12.0"
edition = "2021"
authors = ["Cardinal Cryptography"]
documentation = "https://docs.rs/?"
Expand Down
3 changes: 2 additions & 1 deletion types/src/dataio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_trait::async_trait;

use crate::NodeIndex;
use crate::Round;

/// The source of data items that consensus should order.
///
Expand All @@ -21,5 +22,5 @@ pub trait DataProvider<Data>: Sync + Send + 'static {
pub trait FinalizationHandler<Data>: Sync + Send + 'static {
/// Data, provided by [DataProvider::get_data], has been finalized.
/// The calls to this function follow the order of finalization.
fn data_finalized(&mut self, data: Data, creator: NodeIndex);
fn data_finalized(&mut self, data: Data, creator: NodeIndex, round: Round);
}

0 comments on commit 5267b5b

Please sign in to comment.