Don't sync on top of pruned blocks (#2079)

* Don't sync to pruned blocks

* Typo

Co-Authored-By: arkpar <arkady.paronyan@gmail.com>
This commit is contained in:
Arkadiy Paronyan
2019-03-22 16:27:50 +01:00
committed by GitHub
parent 53f40c583d
commit 704d2a49c7
5 changed files with 59 additions and 21 deletions
+4
View File
@@ -1169,6 +1169,10 @@ impl<Block> client::backend::Backend<Block, Blake2Hasher> for Backend<Block> whe
}
}
fn have_state_at(&self, hash: &Block::Hash, number: NumberFor<Block>) -> bool {
!self.storage.state_db.is_pruned(hash, number.as_())
}
fn destroy_state(&self, mut state: Self::State) -> Result<(), client::error::Error> {
if let Some(hash) = state.parent_hash.clone() {
let is_best = || self.blockchain.meta.read().best_hash == hash;