Add epoch getters to JoinPlan, HB, DHB and QHB.

This commit is contained in:
Andreas Fackler 2018-11-15 15:30:53 +01:00 committed by Andreas Fackler
parent e89688bbd8
commit c94e3ff16f
6 changed files with 26 additions and 4 deletions

View File

@ -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,

View File

@ -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> {

View File

@ -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
}

View File

@ -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.

View File

@ -42,7 +42,7 @@ where
type Epoch = u64;
fn epoch(&self) -> u64 {
self.epoch()
self.next_epoch()
}
}

View File

@ -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>,
{