diff --git a/consensus/src/member.rs b/consensus/src/member.rs index 3bbc939e..540902f0 100644 --- a/consensus/src/member.rs +++ b/consensus/src/member.rs @@ -106,12 +106,13 @@ enum TaskDetails { }, } -pub struct FinalizationHandlerAdapter { +/// This adapter allows to map an implementation of [`FinalizationHandler`] onto implementation of [`UnitFinalizationHandler`]. +pub struct FinalizationHandlerAdapter { finalization_handler: FH, - _phantom: PhantomData

, + _phantom: PhantomData<(D, H)>, } -impl From for FinalizationHandlerAdapter { +impl From for FinalizationHandlerAdapter { fn from(value: FH) -> Self { Self { finalization_handler: value, @@ -121,7 +122,7 @@ impl From for FinalizationHandlerAdapter { } impl> UnitFinalizationHandler - for FinalizationHandlerAdapter + for FinalizationHandlerAdapter { type Data = D; type Hasher = H; @@ -152,7 +153,7 @@ impl< FH: FinalizationHandler, US: AsyncWrite, UL: AsyncRead, - > LocalIO, US, UL> + > LocalIO, US, UL> { pub fn new( data_provider: DP, @@ -621,19 +622,21 @@ where /// [docs for devs](https://cardinal-cryptography.github.io/AlephBFT/index.html) /// or the [original paper](https://arxiv.org/abs/1908.05156). /// -/// Please note that in order to fulfill the constraint [`UnitFinalizationHandler`] -/// it is enough to provide implementation of [`FinalizationHandler`]. We provide -/// implementation of [`UnitFinalizationHandler`] for anything that satisfies -/// [`FinalizationHandler`]. Implementing [`UnitFinalizationHandler`] -/// directly is considered less stable since it exposes intrisics which might be subject to change. -/// Implement [`FinalizationHandler`] instead, unless you absolutely know what you are doing. +/// Please note that in order to fulfill the constraint [`UnitFinalizationHandler`] it is enough to provide implementation of [`FinalizationHandler`]. We provide +/// implementation of [`UnitFinalizationHandler`] for anything that satisfies +/// the trait [`FinalizationHandler`] (by means of [`FinalizationHandlerAdapter`]). Implementing +/// [`UnitFinalizationHandler`] directly is considered less stable since it exposes intrisics which might be +/// subject to change. Implement [`FinalizationHandler`] instead, unless you absolutely know +/// what you are doing. pub async fn run_session< H: Hasher, DP: DataProvider, UFH: UnitFinalizationHandler, US: AsyncWrite + Send + Sync + 'static, UL: AsyncRead + Send + Sync + 'static, - N: Network> + 'static, + N: Network> + + 'static, SH: SpawnHandle, MK: MultiKeychain, >(