mirror of https://github.com/vacp2p/pmtree.git
docs: update readme with Config
This commit is contained in:
parent
ee50bb7318
commit
deac77c2b2
11
README.md
11
README.md
|
@ -23,12 +23,17 @@ In-Memory DB (HashMap) + Keccak
|
||||||
struct MemoryDB(HashMap<DBKey, Value>);
|
struct MemoryDB(HashMap<DBKey, Value>);
|
||||||
struct MyKeccak(Keccak);
|
struct MyKeccak(Keccak);
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct MemoryDBConfig;
|
||||||
|
|
||||||
impl Database for MemoryDB {
|
impl Database for MemoryDB {
|
||||||
fn new(_dbpath: &str) -> Result<Self> {
|
type Config = MemoryDBConfig;
|
||||||
|
|
||||||
|
fn new(_db_config: MemoryDBConfig) -> Result<Self> {
|
||||||
Ok(MemoryDB(HashMap::new()))
|
Ok(MemoryDB(HashMap::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(_dbpath: &str) -> Result<Self> {
|
fn load(_db_config: MemoryDBConfig) -> Result<Self> {
|
||||||
Err(Box::new(Error("Cannot load in-memory DB".to_string())))
|
Err(Box::new(Error("Cannot load in-memory DB".to_string())))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +81,7 @@ impl Hasher for MyKeccak {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut mt = MerkleTree::<MemoryDB, MyKeccak>::new(2, "abacaba").unwrap();
|
let mut mt = MerkleTree::<MemoryDB, MyKeccak>::new(2, MemoryDBConfig).unwrap();
|
||||||
|
|
||||||
assert_eq!(mt.capacity(), 4);
|
assert_eq!(mt.capacity(), 4);
|
||||||
assert_eq!(mt.depth(), 2);
|
assert_eq!(mt.depth(), 2);
|
||||||
|
|
Loading…
Reference in New Issue