fix(cli): remove usage of StageDB on DbTool (#448)

* use view and update instead of StageDB

* change DbTool docs

* clippy
This commit is contained in:
joshieDo
2022-12-15 15:33:49 +08:00
committed by GitHub
parent 43f6bb9127
commit 7b6bf0820e
6 changed files with 72 additions and 62 deletions

View File

@ -2,11 +2,11 @@ use reth_libmdbx::{Environment, NoWriteMap, WriteFlags};
use tempfile::{tempdir, TempDir};
pub fn get_key(n: u32) -> String {
format!("key{}", n)
format!("key{n}")
}
pub fn get_data(n: u32) -> String {
format!("data{}", n)
format!("data{n}")
}
pub fn setup_bench_db(num_rows: u32) -> (TempDir, Environment<NoWriteMap>) {

View File

@ -261,8 +261,7 @@ fn test_concurrent_writers() {
threads.push(thread::spawn(move || {
let txn = writer_env.begin_rw_txn().unwrap();
let db = txn.open_db(None).unwrap();
txn.put(&db, format!("{}{}", key, i), format!("{}{}", val, i), WriteFlags::empty())
.unwrap();
txn.put(&db, format!("{key}{i}"), format!("{val}{i}"), WriteFlags::empty()).unwrap();
txn.commit().is_ok()
}));
}
@ -273,8 +272,8 @@ fn test_concurrent_writers() {
for i in 0..n {
assert_eq!(
Cow::<Vec<u8>>::Owned(format!("{}{}", val, i).into_bytes()),
txn.get(&db, format!("{}{}", key, i).as_bytes()).unwrap().unwrap()
Cow::<Vec<u8>>::Owned(format!("{val}{i}").into_bytes()),
txn.get(&db, format!("{key}{i}").as_bytes()).unwrap().unwrap()
);
}
}