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 43069e0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
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/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
4 changes: 3 additions & 1 deletion types/src/dataio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use async_trait::async_trait;

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


/// The source of data items that consensus should order.
///
Expand All @@ -21,5 +23,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 43069e0

Please sign in to comment.