Correctly update range status when outdated chains are removed (#2827)

We were batch removing chains when purging, and then updating the status of the collection for each of those. This makes the range status be out of sync with the real status. This represented no harm to the global sync status, but I've changed it to comply with a correct debug assertion that I got triggered while doing some testing.
Also added tests and improved code quality as per @paulhauner 's suggestions.
This commit is contained in:
Divma
2021-11-26 01:13:49 +00:00
parent 9eedb6b888
commit 413b0b5b2b
5 changed files with 94 additions and 45 deletions

View File

@@ -62,10 +62,10 @@ impl<T: EthSpec> SyncNetworkContext<T> {
pub fn status_peers<C: ToStatusMessage>(
&mut self,
chain: C,
chain: &C,
peers: impl Iterator<Item = PeerId>,
) {
if let Ok(status_message) = &chain.status_message() {
if let Ok(status_message) = chain.status_message() {
for peer_id in peers {
debug!(
self.log,