Merge pull request #54 from gavofyork/gav
Make clear when the panic occurs to a missing trie root.
This commit is contained in:
commit
e755f74d2e
@ -1,10 +1,7 @@
|
|||||||
use std::fmt;
|
use common::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use hash::*;
|
|
||||||
use nibbleslice::*;
|
use nibbleslice::*;
|
||||||
use bytes::*;
|
|
||||||
use rlp::*;
|
use rlp::*;
|
||||||
use std::collections::HashMap;
|
|
||||||
use super::trietraits::*;
|
use super::trietraits::*;
|
||||||
use super::node::*;
|
use super::node::*;
|
||||||
|
|
||||||
@ -44,7 +41,10 @@ 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 {
|
||||||
assert!(db.exists(root));
|
if !db.exists(root) {
|
||||||
|
flush(format!("Trie root not found {}", root));
|
||||||
|
panic!("Trie root not found!");
|
||||||
|
}
|
||||||
TrieDB {
|
TrieDB {
|
||||||
db: db,
|
db: db,
|
||||||
root: root,
|
root: root,
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
use std::fmt;
|
use common::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use hash::*;
|
|
||||||
use nibbleslice::*;
|
use nibbleslice::*;
|
||||||
use bytes::*;
|
|
||||||
use rlp::*;
|
use rlp::*;
|
||||||
use std::collections::HashMap;
|
|
||||||
use super::node::*;
|
use super::node::*;
|
||||||
use super::journal::*;
|
use super::journal::*;
|
||||||
use super::trietraits::*;
|
use super::trietraits::*;
|
||||||
@ -71,7 +68,10 @@ impl<'db> TrieDBMut<'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 from_existing(db: &'db mut HashDB, root: &'db mut H256) -> Self {
|
pub fn from_existing(db: &'db mut HashDB, root: &'db mut H256) -> Self {
|
||||||
assert!(db.exists(root));
|
if !db.exists(root) {
|
||||||
|
flush(format!("Trie root not found {}", root));
|
||||||
|
panic!("Trie root not found!");
|
||||||
|
}
|
||||||
TrieDBMut {
|
TrieDBMut {
|
||||||
db: db,
|
db: db,
|
||||||
root: root,
|
root: root,
|
||||||
|
Loading…
Reference in New Issue
Block a user