review comments

This commit is contained in:
Vladimir Komendantskiy 2018-07-13 22:53:44 +01:00
parent 03153cf788
commit db9191768b
6 changed files with 14 additions and 17 deletions

View File

@ -208,7 +208,7 @@ pub struct Agreement<NodeUid> {
coin_schedule: CoinSchedule,
}
pub type AgreementStep<N> = Step<N, bool>;
pub type AgreementStep<NodeUid> = Step<NodeUid, bool>;
impl<NodeUid: Clone + Debug + Ord> DistAlgorithm for Agreement<NodeUid> {
type NodeUid = NodeUid;
@ -230,11 +230,11 @@ impl<NodeUid: Clone + Debug + Ord> DistAlgorithm for Agreement<NodeUid> {
) -> AgreementResult<AgreementStep<NodeUid>> {
let fault_log = if self.terminated || message.epoch < self.epoch {
// Message is obsolete: We are already in a later epoch or terminated.
FaultLog::default()
FaultLog::new()
} else if message.epoch > self.epoch {
// Message is for a later epoch. We can't handle that yet.
self.incoming_queue.push((sender_id.clone(), message));
FaultLog::default()
FaultLog::new()
} else {
match message.content {
AgreementContent::BVal(b) => self.handle_bval(sender_id, b)?,
@ -502,8 +502,7 @@ impl<NodeUid: Clone + Debug + Ord> Agreement<NodeUid> {
&mut self,
coin_step: CommonCoinStep<NodeUid>,
) -> AgreementResult<FaultLog<NodeUid>> {
let mut fault_log = FaultLog::new();
fault_log.extend(coin_step.fault_log);
let mut fault_log = coin_step.fault_log.clone();
if let Some(coin) = coin_step.output.into_iter().next() {
let def_bin_value = self.count_conf().1.definite();
fault_log.extend(self.on_coin(coin, def_bin_value)?);
@ -604,7 +603,7 @@ impl<NodeUid: Clone + Debug + Ord> Agreement<NodeUid> {
self.on_coin_step(coin_step)
} else {
// Continue waiting for (N - f) `Conf` messages
Ok(FaultLog::default())
Ok(FaultLog::new())
}
}

View File

@ -78,7 +78,7 @@ pub struct CommonCoin<NodeUid, T> {
terminated: bool,
}
pub type CommonCoinStep<N> = Step<N, bool>;
pub type CommonCoinStep<NodeUid> = Step<NodeUid, bool>;
impl<NodeUid, T> DistAlgorithm for CommonCoin<NodeUid, T>
where
@ -112,7 +112,7 @@ where
let CommonCoinMessage(share) = message;
self.handle_share(sender_id, share)?
} else {
FaultLog::default()
FaultLog::new()
};
self.step(fault_log)
}

View File

@ -258,7 +258,7 @@ impl<NodeUid: Clone + Debug + Ord + Rand> CommonSubset<NodeUid> {
// FIXME: Use the result.
agreement.input(true)
} else {
Ok(Default::default())
Ok(Step::default())
}
};
self.process_agreement(proposer_id, set_agreement_input)?

View File

@ -184,7 +184,7 @@ where
NodeUid: Eq + Ord + Clone + Debug + Serialize + for<'r> Deserialize<'r> + Hash + Rand,
{
fn step(&mut self, fault_log: FaultLog<NodeUid>) -> Result<DynamicHoneyBadgerStep<C, NodeUid>> {
Ok(Step::new(self.output.drain(0..).collect(), fault_log))
Ok(Step::new(self.output.drain(..).collect(), fault_log))
}
/// Returns a new `DynamicHoneyBadgerBuilder` configured to use the node IDs and cryptographic
@ -252,7 +252,7 @@ where
self.key_gen_msg_buffer.push(tx);
// FIXME: Remove the call to `process_output`. There wasn't any output from HB in this
// function.
self.process_output(Default::default())
self.process_output(Step::default())
}
/// Processes all pending batches output by Honey Badger.

View File

@ -179,7 +179,7 @@ where
&mut self,
fault_log: FaultLog<NodeUid>,
) -> HoneyBadgerResult<HoneyBadgerStep<C, NodeUid>> {
Ok(Step::new(self.output.drain(0..).collect(), fault_log))
Ok(Step::new(self.output.drain(..).collect(), fault_log))
}
/// Proposes a new item in the current epoch.
@ -554,8 +554,7 @@ where
&mut self,
step: CommonSubsetStep<NodeUid>,
) -> HoneyBadgerResult<FaultLog<NodeUid>> {
let mut fault_log = FaultLog::new();
fault_log.extend(step.fault_log);
let mut fault_log = step.fault_log.clone();
for cs_output in step.output {
fault_log.extend(self.send_decryption_shares(cs_output)?);
// TODO: May also check that there is no further output from Common Subset.

View File

@ -158,8 +158,7 @@ where
message: Self::Message,
) -> Result<QueueingHoneyBadgerStep<Tx, NodeUid>> {
let step = self.dyn_hb.handle_message(sender_id, message)?;
let mut fault_log = FaultLog::new();
fault_log.extend(step.fault_log);
let mut fault_log = step.fault_log.clone();
for batch in step.output {
self.queue.remove_all(batch.iter());
self.output.push_back(batch);
@ -198,7 +197,7 @@ where
&mut self,
fault_log: FaultLog<NodeUid>,
) -> Result<QueueingHoneyBadgerStep<Tx, NodeUid>> {
Ok(Step::new(self.output.drain(0..).collect(), fault_log))
Ok(Step::new(self.output.drain(..).collect(), fault_log))
}
/// Returns a reference to the internal `DynamicHoneyBadger` instance.