Fixed signers cache after block replace.

This commit is contained in:
Revertron
2021-04-27 12:17:52 +02:00
parent 5afd9906b3
commit daf6c23967
+6
View File
@@ -250,6 +250,7 @@ impl Chain {
pub fn replace_block(&mut self, block: Block) -> sqlite::Result<()> {
warn!("Replacing block {} with:\n{:?}", block.index, &block);
self.signers.borrow_mut().clear();
self.truncate_db_from_block(block.index)?;
self.add_block(block);
Ok(())
@@ -975,6 +976,11 @@ impl SignersCache {
pub fn has_signers_for(&self, index: u64) -> bool {
self.index == index && !self.signers.is_empty()
}
pub fn clear(&mut self) {
self.index = 0;
self.signers.clear();
}
}
#[cfg(test)]