fix(rpc/eth): remove cache when reorg occured (#9775)

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
Delweng
2024-07-25 05:32:32 +08:00
committed by GitHub
parent 6b1fbf82b7
commit 7531366449

View File

@ -61,15 +61,12 @@ where
}
}
/// Remove consumers for a given key.
/// Remove consumers for a given key, this will also remove the key from the cache.
pub fn remove(&mut self, key: &K) -> Option<Vec<S>> {
match self.queued.remove(key) {
Some(removed) => {
self.metrics.queued_consumers_count.decrement(removed.len() as f64);
Some(removed)
}
None => None,
}
let _ = self.cache.remove(key);
self.queued
.remove(key)
.inspect(|removed| self.metrics.queued_consumers_count.decrement(removed.len() as f64))
}
/// Returns a reference to the value for a given key and promotes that element to be the most