diff --git a/util/patricia_trie/src/fatdb.rs b/util/patricia_trie/src/fatdb.rs
index 4cdd131c95a..3d96564c934 100644
--- a/util/patricia_trie/src/fatdb.rs
+++ b/util/patricia_trie/src/fatdb.rs
@@ -14,10 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use ethereum_types::H256;
-use keccak::keccak;
use hashdb::{HashDB, Hasher};
use super::{TrieDB, Trie, TrieDBIterator, TrieItem, TrieIterator, Query};
+use rlp::{Decodable, Encodable};
/// A `Trie` implementation which hashes keys and uses a generic `HashDB` backing database.
/// Additionaly it stores inserted hash-key mappings for later retrieval.
@@ -27,43 +26,35 @@ pub struct FatDB<'db, H: Hasher + 'db> {
raw: TrieDB<'db, H>,
}
-impl<'db, H: Hasher> FatDB<'db, H> {
+impl<'db, H: Hasher> FatDB<'db, H> where H::Out: Decodable {
/// Create a new trie with the backing database `db` and empty `root`
/// Initialise to the state entailed by the genesis block.
/// This guarantees the trie is built correctly.
- pub fn new(db: &'db HashDB, root: &'db H256) -> super::Result {
- let fatdb = FatDB {
- raw: TrieDB::new(db, root)?
- };
-
- Ok(fatdb)
+ pub fn new(db: &'db HashDB, root: &'db H::Out) -> super::Result {
+ Ok(FatDB { raw: TrieDB::new(db, root)? })
}
/// Get the backing database.
- pub fn db(&self) -> &HashDB {
- self.raw.db()
- }
+ pub fn db(&self) -> &HashDB { self.raw.db() }
}
-impl<'db, H: Hasher> Trie for FatDB<'db, H> {
+impl<'db, H: Hasher> Trie for FatDB<'db, H> where H::Out: Decodable + Encodable {
type H = H;
- fn root(&self) -> &::Out {
- self.raw.root()
- }
+ fn root(&self) -> &::Out { self.raw.root() }
- fn contains(&self, key: &[u8]) -> super::Result {
- self.raw.contains(&keccak(key)) // TODO
+ fn contains(&self, key: &[u8]) -> super::Result::Out> {
+ self.raw.contains(&Self::H::hash(key).as_ref())
}
- fn get_with<'a, 'key, Q: Query>(&'a self, key: &'key [u8], query: Q) -> super::Result