citahub / cita_trie

Rust implementation of the Modified Patricia Tree (aka Trie).
Apache License 2.0
71 stars 28 forks source link

fix: Avoid delete stale root. #30

Closed yejiayu closed 5 years ago

yejiayu commented 5 years ago

cc @mohanson

mohanson commented 5 years ago

Look good to me. I will test it on vm next day.

mohanson commented 5 years ago

Paniced in some test cases. Quick recurrent:

use cita_trie::trie::Trie;
let mut memdb = cita_trie::db::MemoryDB::new();

let mut trie = cita_trie::trie::PatriciaTrie::new(
    &mut memdb,
    cita_trie::codec::RLPNodeCodec::default(),
);
trie.insert(b"test", b"test").unwrap();
trie.insert(b"test1", b"test").unwrap();
trie.insert(b"test2", b"test").unwrap();
trie.insert(b"test23", b"test").unwrap();
trie.insert(b"test33", b"test").unwrap();
trie.insert(b"test44", b"test").unwrap();
let r = trie.root().unwrap();

println!("{:?}", trie.get(b"test"));
thread 'main' panicked at 'index out of bounds: the len is 16 but the index is 16', C:\src\cita-trie\src\node.rs:90:10
note: Run with `RUST_BACKTRACE=1` for a backtrace.
yejiayu commented 5 years ago

ping @mohanson