mirror of https://github.com/poanetwork/hbbft.git
Fix removal of terminated CS instances in HB.
This commit is contained in:
parent
78ab9742a9
commit
8346085fb9
|
@ -252,7 +252,7 @@ where
|
|||
cs.handle_message(sender_id, message)?
|
||||
};
|
||||
let step = self.process_output(cs_step, epoch)?;
|
||||
self.remove_terminated(epoch);
|
||||
self.remove_terminated();
|
||||
Ok(step)
|
||||
}
|
||||
|
||||
|
@ -558,13 +558,15 @@ where
|
|||
}
|
||||
|
||||
/// Removes all `CommonSubset` instances from _past_ epochs that have terminated.
|
||||
fn remove_terminated(&mut self, from_epoch: u64) {
|
||||
for epoch in from_epoch..self.epoch {
|
||||
if self
|
||||
fn remove_terminated(&mut self) {
|
||||
let terminated_epochs: Vec<u64> = self
|
||||
.common_subsets
|
||||
.get(&epoch)
|
||||
.map_or(false, CommonSubset::terminated)
|
||||
{
|
||||
.iter()
|
||||
.take_while(|&(epoch, _)| *epoch < self.epoch)
|
||||
.filter(|&(_, cs)| cs.terminated())
|
||||
.map(|(epoch, _)| *epoch)
|
||||
.collect();
|
||||
for epoch in terminated_epochs {
|
||||
debug!(
|
||||
"{:?} Epoch {} has terminated.",
|
||||
self.netinfo.our_uid(),
|
||||
|
@ -574,7 +576,6 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A batch of contributions the algorithm has output.
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
Loading…
Reference in New Issue