Remove (almost all) panickers from trie module (#1776)
* memorydb ub patch and other cleanup * fix denote invocations * move trie traits into trie module * replace "denote" with shim * triedb returns results and no longer panics * fix warnings * get ethcore compiling * warn on trie errors in ethcore * remove unsafety from node decoder * restore broken denote behavior for this branch * fix overlayrecent fallout * fix triedb tests * remove unwrap in state * alter Trie::get to return Result<Option<_>> * fix refcell error in require * fix test warnings * fix json tests * whitespace [ci:skip] * Avoid unneeded match/indentation * whitespace * prettify map_or_else * remove test warning
This commit is contained in:
committed by
Gav Wood
parent
40a304b177
commit
11b65ce53d
@@ -25,6 +25,8 @@ use super::seal::Generic as GenericSeal;
|
||||
use ethereum;
|
||||
use ethjson;
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
/// Parameters common to all engines.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct CommonParams {
|
||||
@@ -226,21 +228,21 @@ impl Spec {
|
||||
}
|
||||
|
||||
/// Ensure that the given state DB has the trie nodes in for the genesis state.
|
||||
pub fn ensure_db_good(&self, db: &mut HashDB) -> bool {
|
||||
pub fn ensure_db_good(&self, db: &mut HashDB) -> Result<bool, Box<TrieError>> {
|
||||
if !db.contains(&self.state_root()) {
|
||||
let mut root = H256::new();
|
||||
{
|
||||
let mut t = SecTrieDBMut::new(db, &mut root);
|
||||
for (address, account) in self.genesis_state.get().iter() {
|
||||
t.insert(address.as_slice(), &account.rlp());
|
||||
try!(t.insert(address.as_slice(), &account.rlp()));
|
||||
}
|
||||
}
|
||||
for (address, account) in self.genesis_state.get().iter() {
|
||||
account.insert_additional(&mut AccountDBMut::new(db, address));
|
||||
}
|
||||
assert!(db.contains(&self.state_root()));
|
||||
true
|
||||
} else { false }
|
||||
Ok(true)
|
||||
} else { Ok(false) }
|
||||
}
|
||||
|
||||
/// Loads spec from json file.
|
||||
|
||||
Reference in New Issue
Block a user