Merge pull request #1217 from rphmeier/state_at_state_root
Verify the state root exists before creating a State
This commit is contained in:
@@ -175,6 +175,8 @@ impl JournalDB for ArchiveDB {
|
||||
fn state(&self, id: &H256) -> Option<Bytes> {
|
||||
self.backing.get_by_prefix(&id.bytes()[0..12]).and_then(|b| Some(b.to_vec()))
|
||||
}
|
||||
|
||||
fn is_pruned(&self) -> bool { false }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -42,4 +42,7 @@ pub trait JournalDB : HashDB + Send + Sync {
|
||||
fn state(&self, _id: &H256) -> Option<Bytes> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Whether this database is pruned.
|
||||
fn is_pruned(&self) -> bool { true }
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ impl<'db> TrieDB<'db> {
|
||||
/// Create a new trie with the backing database `db` and `root`
|
||||
/// Panics, if `root` does not exist
|
||||
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);
|
||||
panic!("Trie root not found!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user