exists -> contains
This commit is contained in:
parent
6c6229c963
commit
1e10445f82
@ -371,19 +371,23 @@ impl<V> Client<V> where V: Verifier {
|
|||||||
return Some(self.state())
|
return Some(self.state())
|
||||||
}
|
}
|
||||||
|
|
||||||
let block_number = self.block_number(id.clone());
|
let block_number = match self.block_number(id.clone()) {
|
||||||
|
Some(num) => num,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
self.block_header(id).and_then(|header| {
|
self.block_header(id).and_then(|header| {
|
||||||
|
let db = self.state_db.lock().unwrap().boxed_clone();
|
||||||
|
|
||||||
let root = HeaderView::new(&header).state_root();
|
let root = HeaderView::new(&header).state_root();
|
||||||
// check that the block is not too old -- blocks within `HISTORY` blocks of the best will
|
// check that the block is not too old -- blocks within `HISTORY` blocks of the best will
|
||||||
// always be available. If the block could be too old, check if its state root is valid.
|
// always be available. If the block could be too old, check if its state root is valid.
|
||||||
if self.state_db.does_pruning()
|
if db.does_pruning()
|
||||||
&& self.best_block_number() >= block_number + HISTORY
|
&& self.chain.best_block_number() >= block_number + HISTORY
|
||||||
&& self.state_db.exists(root) {
|
&& !db.contains(&root) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = self.state_db.lock().unwrap().boxed_clone();
|
|
||||||
Some(State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce()))
|
Some(State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ impl<'db> TrieDB<'db> {
|
|||||||
/// Create a new trie with the backing database `db` and `root`
|
/// Create a new trie with the backing database `db` and `root`
|
||||||
/// Panics, if `root` does not exist
|
/// Panics, if `root` does not exist
|
||||||
pub fn new(db: &'db HashDB, root: &'db H256) -> Self {
|
pub fn new(db: &'db HashDB, root: &'db H256) -> Self {
|
||||||
if !db.exists(root) {
|
if !db.contains(root) {
|
||||||
flushln!("TrieDB::new({}): Trie root not found!", root);
|
flushln!("TrieDB::new({}): Trie root not found!", root);
|
||||||
panic!("Trie root not found!");
|
panic!("Trie root not found!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user