from_existing works for an empty DB if passed empty RLP SHA3.

This commit is contained in:
Gav Wood 2016-01-14 23:13:28 +01:00
parent d2cc3b9b5b
commit b781fe6753

View File

@ -71,6 +71,9 @@ impl<'db> TrieDBMut<'db> {
/// Create a new trie with the backing database `db` and `root`
/// Panics, if `root` does not exist
pub fn from_existing(db: &'db mut HashDB, root: &'db mut H256) -> Self {
if !db.exists(root) && root == &SHA3_NULL_RLP {
*root = db.insert(&NULL_RLP);
}
assert!(db.exists(root));
TrieDBMut {
db: db,