mirror of https://github.com/poanetwork/hbbft.git
Enable DynamicHoneyBadgers to rejoin after connection loss (#366)
Implementing an epoch setter for the `DynamicHoneyBadgerBuilder` enables the creation of a `DynamicHoneyBadger` that will join the consensus at a given epoch.
This commit is contained in:
parent
742ad7b83a
commit
c887b6810b
|
@ -15,6 +15,8 @@ use crate::{Contribution, NetworkInfo, NodeIdT};
|
|||
pub struct DynamicHoneyBadgerBuilder<C, N> {
|
||||
/// Start in this era.
|
||||
era: u64,
|
||||
/// Start in this epoch.
|
||||
epoch: u64,
|
||||
/// Parameters controlling Honey Badger's behavior and performance.
|
||||
params: Params,
|
||||
_phantom: PhantomData<(C, N)>,
|
||||
|
@ -24,6 +26,7 @@ impl<C, N: Ord> Default for DynamicHoneyBadgerBuilder<C, N> {
|
|||
fn default() -> Self {
|
||||
DynamicHoneyBadgerBuilder {
|
||||
era: 0,
|
||||
epoch: 0,
|
||||
params: Params::default(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
|
@ -47,6 +50,12 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the starting era to the given value.
|
||||
pub fn epoch(&mut self, epoch: u64) -> &mut Self {
|
||||
self.epoch = epoch;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum number of future epochs for which we handle messages simultaneously.
|
||||
pub fn max_future_epochs(&mut self, max_future_epochs: u64) -> &mut Self {
|
||||
self.params.max_future_epochs = max_future_epochs;
|
||||
|
@ -78,6 +87,7 @@ where
|
|||
pub fn build(&mut self, netinfo: NetworkInfo<N>) -> DynamicHoneyBadger<C, N> {
|
||||
let DynamicHoneyBadgerBuilder {
|
||||
era,
|
||||
epoch,
|
||||
params,
|
||||
_phantom,
|
||||
} = self;
|
||||
|
@ -85,6 +95,7 @@ where
|
|||
|
||||
let honey_badger = HoneyBadger::builder(arc_netinfo.clone())
|
||||
.session_id(*era)
|
||||
.epoch(*epoch)
|
||||
.params(params.clone())
|
||||
.build();
|
||||
|
||||
|
|
Loading…
Reference in New Issue