This repository was archived by the owner on Nov 6, 2020. It is now read-only.
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Modifications for better cross-project use of HashDB/Patricia Trie #7019
Closed
Description
cc @debris
HashDB interface currently uses local primitive types, while with the primitives
crate approach local types can be used. Also the assumption on keccak is not likely to remain strong.
A modification of the interface from
trait HashDB {
fn insert(&mut self, value: Vec<u8>) -> H256;
....
}
trait HashFunction {
type Out: Debug + PartialEq + Eq + Clone + Copy + Hash + Send + Sync;
fn hash(x: &[u8]) -> Self::Out;
}
trait HashDB<F: HashFunction> {
fn insert(&mut self, value: Vec<u8>) -> F::Out;
....
}
would be a definite improvement and lead to the crate carrying around fewer dependencies.
One problem is the special-casing of many known hashes like NULL_RLP, RLP_EMPTY, etc. in the patricia trie or in memory db. How can we handle the special cases correctly without re-hashing or doing extra work on each hash?