mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #394 from poanetwork/afck-qhb-duplicate-aux
Fix BA message handling on epoch change.
This commit is contained in:
commit
a64f62506d
|
@ -258,9 +258,11 @@ impl<N: NodeIdT, S: SessionIdT> BinaryAgreement<N, S> {
|
|||
let received = epoch_state
|
||||
.entry(sender_id.clone())
|
||||
.or_insert_with(ReceivedMessages::new);
|
||||
Ok(received.insert(content).map_or(Step::default(), |fault| {
|
||||
Fault::new(sender_id.clone(), fault).into()
|
||||
}))
|
||||
Ok(received
|
||||
.insert(content)
|
||||
.map_or_else(Step::default, |fault| {
|
||||
Fault::new(sender_id.clone(), fault).into()
|
||||
}))
|
||||
} else {
|
||||
self.handle_message_content(sender_id, content)
|
||||
}
|
||||
|
@ -504,15 +506,12 @@ impl<N: NodeIdT, S: SessionIdT> BinaryAgreement<N, S> {
|
|||
self.estimated = Some(b);
|
||||
let sbvb_step = self.sbv_broadcast.send_bval(b)?;
|
||||
let mut step = self.handle_sbvb_step(sbvb_step)?;
|
||||
let epoch_state = self
|
||||
.incoming_queue
|
||||
.remove(&self.epoch)
|
||||
.into_iter()
|
||||
.flatten();
|
||||
let epoch = self.epoch;
|
||||
let epoch_state = self.incoming_queue.remove(&epoch).into_iter().flatten();
|
||||
for (sender_id, received) in epoch_state {
|
||||
for m in received.messages() {
|
||||
step.extend(self.handle_message_content(&sender_id, m)?);
|
||||
if self.decision.is_some() {
|
||||
if self.decision.is_some() || self.epoch > epoch {
|
||||
return Ok(step);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,12 +112,10 @@ impl<N: NodeIdT> SbvBroadcast<N> {
|
|||
/// Upon receiving _f + 1_ `BVal(b)`, multicasts `BVal(b)`. Upon receiving _2 f + 1_ `BVal(b)`,
|
||||
/// updates `bin_values`. When `bin_values` gets its first entry, multicasts `Aux(b)`.
|
||||
pub fn handle_bval(&mut self, sender_id: &N, b: bool) -> Result<Step<N>> {
|
||||
let count_bval = {
|
||||
if !self.received_bval[b].insert(sender_id.clone()) {
|
||||
return Ok(Fault::new(sender_id.clone(), FaultKind::DuplicateBVal).into());
|
||||
}
|
||||
self.received_bval[b].len()
|
||||
};
|
||||
if !self.received_bval[b].insert(sender_id.clone()) {
|
||||
return Ok(Fault::new(sender_id.clone(), FaultKind::DuplicateBVal).into());
|
||||
}
|
||||
let count_bval = self.received_bval[b].len();
|
||||
|
||||
let mut step = Step::default();
|
||||
|
||||
|
|
Loading…
Reference in New Issue