mirror of https://github.com/poanetwork/hbbft.git
Add epoch getters to JoinPlan, HB, DHB and QHB.
This commit is contained in:
parent
e89688bbd8
commit
c94e3ff16f
|
@ -200,6 +200,11 @@ where
|
|||
!self.key_gen_msg_buffer.is_empty()
|
||||
}
|
||||
|
||||
/// The epoch of the next batch that will be output.
|
||||
pub fn next_epoch(&self) -> u64 {
|
||||
self.era + self.honey_badger.next_epoch()
|
||||
}
|
||||
|
||||
/// Handles a message for the `HoneyBadger` instance.
|
||||
fn handle_honey_badger_message(
|
||||
&mut self,
|
||||
|
|
|
@ -151,6 +151,13 @@ pub struct JoinPlan<N: Ord> {
|
|||
random_value: bool,
|
||||
}
|
||||
|
||||
impl<N: Ord> JoinPlan<N> {
|
||||
/// The epoch of the first batch the new node will observe.
|
||||
pub fn next_epoch(&self) -> u64 {
|
||||
self.era
|
||||
}
|
||||
}
|
||||
|
||||
/// The ongoing key generation, together with information about the validator change.
|
||||
#[derive(Debug)]
|
||||
struct KeyGenState<N: Ord> {
|
||||
|
|
|
@ -140,8 +140,8 @@ where
|
|||
self.encryption_schedule
|
||||
}
|
||||
|
||||
/// Returns the current epoch.
|
||||
pub fn epoch(&self) -> u64 {
|
||||
/// Returns the epoch of the next batch that will be output.
|
||||
pub fn next_epoch(&self) -> u64 {
|
||||
self.epoch
|
||||
}
|
||||
|
||||
|
|
|
@ -300,6 +300,11 @@ where
|
|||
Ok(step.join(self.propose()?))
|
||||
}
|
||||
|
||||
/// Returns the epoch of the next batch that will be output.
|
||||
pub fn next_epoch(&self) -> u64 {
|
||||
self.dyn_hb.next_epoch()
|
||||
}
|
||||
|
||||
/// Returns `true` if we are ready to propose our contribution for the next epoch, i.e. if the
|
||||
/// previous epoch has completed and we have either pending transactions or we are required to
|
||||
/// make a proposal to avoid stalling the network.
|
||||
|
|
|
@ -42,7 +42,7 @@ where
|
|||
type Epoch = u64;
|
||||
|
||||
fn epoch(&self) -> u64 {
|
||||
self.epoch()
|
||||
self.next_epoch()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,9 +146,14 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns an immutable reference to the wrapped algorithm.
|
||||
pub fn inner(&self) -> &D {
|
||||
&self.algo
|
||||
}
|
||||
|
||||
/// Applies `f` to the wrapped algorithm and converts the step in the result to a sender queue
|
||||
/// step, deferring or dropping messages, where necessary.
|
||||
pub fn apply<F>(&mut self, f: F) -> Result<DaStep<Self>, D::Error>
|
||||
fn apply<F>(&mut self, f: F) -> Result<DaStep<Self>, D::Error>
|
||||
where
|
||||
F: FnOnce(&mut D) -> Result<DaStep<D>, D::Error>,
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue