mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #173 from poanetwork/afck-hb-clear-cs
Fix removal of terminated CS instances in HB.
This commit is contained in:
commit
062b7150e1
|
@ -307,7 +307,7 @@ where
|
||||||
.map_err(ErrorKind::HandleCommonMessageCommonSubset1)?
|
.map_err(ErrorKind::HandleCommonMessageCommonSubset1)?
|
||||||
};
|
};
|
||||||
let step = self.process_output(cs_step, epoch)?;
|
let step = self.process_output(cs_step, epoch)?;
|
||||||
self.remove_terminated(epoch);
|
self.remove_terminated();
|
||||||
Ok(step)
|
Ok(step)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,20 +613,21 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all `CommonSubset` instances from _past_ epochs that have terminated.
|
/// Removes all `CommonSubset` instances from _past_ epochs that have terminated.
|
||||||
fn remove_terminated(&mut self, from_epoch: u64) {
|
fn remove_terminated(&mut self) {
|
||||||
for epoch in from_epoch..self.epoch {
|
let terminated_epochs: Vec<u64> = self
|
||||||
if self
|
.common_subsets
|
||||||
.common_subsets
|
.iter()
|
||||||
.get(&epoch)
|
.take_while(|&(epoch, _)| *epoch < self.epoch)
|
||||||
.map_or(false, CommonSubset::terminated)
|
.filter(|&(_, cs)| cs.terminated())
|
||||||
{
|
.map(|(epoch, _)| *epoch)
|
||||||
debug!(
|
.collect();
|
||||||
"{:?} Epoch {} has terminated.",
|
for epoch in terminated_epochs {
|
||||||
self.netinfo.our_uid(),
|
debug!(
|
||||||
epoch
|
"{:?} Epoch {} has terminated.",
|
||||||
);
|
self.netinfo.our_uid(),
|
||||||
self.common_subsets.remove(&epoch);
|
epoch
|
||||||
}
|
);
|
||||||
|
self.common_subsets.remove(&epoch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue