Merge pull request #689 from ethcore/jdbrenames

Rename into something that is a little more descriptive.
This commit is contained in:
Gav Wood 2016-03-12 11:36:55 +01:00
commit 3250e36b4a
3 changed files with 61 additions and 61 deletions

View File

@ -32,7 +32,7 @@ use std::env;
/// write operations out to disk. Unlike OverlayDB, `remove()` operations do not take effect /// write operations out to disk. Unlike OverlayDB, `remove()` operations do not take effect
/// immediately. Rather some age (based on a linear but arbitrary metric) must pass before /// immediately. Rather some age (based on a linear but arbitrary metric) must pass before
/// the removals actually take effect. /// the removals actually take effect.
pub struct OptionOneDB { pub struct EarlyMergeDB {
overlay: MemoryDB, overlay: MemoryDB,
backing: Arc<Database>, backing: Arc<Database>,
counters: Option<Arc<RwLock<HashMap<H256, i32>>>>, counters: Option<Arc<RwLock<HashMap<H256, i32>>>>,
@ -44,9 +44,9 @@ const VERSION_KEY : [u8; 12] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0
const DB_VERSION : u32 = 3; const DB_VERSION : u32 = 3;
const PADDING : [u8; 10] = [ 0u8; 10 ]; const PADDING : [u8; 10] = [ 0u8; 10 ];
impl OptionOneDB { impl EarlyMergeDB {
/// Create a new instance from file /// Create a new instance from file
pub fn new(path: &str) -> OptionOneDB { pub fn new(path: &str) -> EarlyMergeDB {
let opts = DatabaseConfig { let opts = DatabaseConfig {
prefix_size: Some(12) //use 12 bytes as prefix, this must match account_db prefix prefix_size: Some(12) //use 12 bytes as prefix, this must match account_db prefix
}; };
@ -62,8 +62,8 @@ impl OptionOneDB {
backing.put(&VERSION_KEY, &encode(&DB_VERSION)).expect("Error writing version to database"); backing.put(&VERSION_KEY, &encode(&DB_VERSION)).expect("Error writing version to database");
} }
let counters = Some(Arc::new(RwLock::new(OptionOneDB::read_counters(&backing)))); let counters = Some(Arc::new(RwLock::new(EarlyMergeDB::read_counters(&backing))));
OptionOneDB { EarlyMergeDB {
overlay: MemoryDB::new(), overlay: MemoryDB::new(),
backing: Arc::new(backing), backing: Arc::new(backing),
counters: counters, counters: counters,
@ -72,7 +72,7 @@ impl OptionOneDB {
/// Create a new instance with an anonymous temporary database. /// Create a new instance with an anonymous temporary database.
#[cfg(test)] #[cfg(test)]
fn new_temp() -> OptionOneDB { fn new_temp() -> EarlyMergeDB {
let mut dir = env::temp_dir(); let mut dir = env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
Self::new(dir.to_str().unwrap()) Self::new(dir.to_str().unwrap())
@ -193,7 +193,7 @@ impl OptionOneDB {
} }
} }
impl HashDB for OptionOneDB { impl HashDB for EarlyMergeDB {
fn keys(&self) -> HashMap<H256, i32> { fn keys(&self) -> HashMap<H256, i32> {
let mut ret: HashMap<H256, i32> = HashMap::new(); let mut ret: HashMap<H256, i32> = HashMap::new();
for (key, _) in self.backing.iter() { for (key, _) in self.backing.iter() {
@ -238,9 +238,9 @@ impl HashDB for OptionOneDB {
} }
} }
impl JournalDB for OptionOneDB { impl JournalDB for EarlyMergeDB {
fn spawn(&self) -> Box<JournalDB> { fn spawn(&self) -> Box<JournalDB> {
Box::new(OptionOneDB { Box::new(EarlyMergeDB {
overlay: MemoryDB::new(), overlay: MemoryDB::new(),
backing: self.backing.clone(), backing: self.backing.clone(),
counters: self.counters.clone(), counters: self.counters.clone(),
@ -369,11 +369,11 @@ impl JournalDB for OptionOneDB {
try!(batch.delete(&last)); try!(batch.delete(&last));
index += 1; index += 1;
} }
trace!("OptionOneDB: delete journal for time #{}.{}, (canon was {})", end_era, index, canon_id); trace!("EarlyMergeDB: delete journal for time #{}.{}, (canon was {})", end_era, index, canon_id);
} }
try!(self.backing.write(batch)); try!(self.backing.write(batch));
// trace!("OptionOneDB::commit() deleted {} nodes", deletes); // trace!("EarlyMergeDB::commit() deleted {} nodes", deletes);
Ok(0) Ok(0)
} }
} }
@ -388,7 +388,7 @@ mod tests {
#[test] #[test]
fn insert_same_in_fork() { fn insert_same_in_fork() {
// history is 1 // history is 1
let mut jdb = OptionOneDB::new_temp(); let mut jdb = EarlyMergeDB::new_temp();
let x = jdb.insert(b"X"); let x = jdb.insert(b"X");
jdb.commit(1, &b"1".sha3(), None).unwrap(); jdb.commit(1, &b"1".sha3(), None).unwrap();
@ -410,7 +410,7 @@ mod tests {
#[test] #[test]
fn long_history() { fn long_history() {
// history is 3 // history is 3
let mut jdb = OptionOneDB::new_temp(); let mut jdb = EarlyMergeDB::new_temp();
let h = jdb.insert(b"foo"); let h = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.exists(&h)); assert!(jdb.exists(&h));
@ -428,7 +428,7 @@ mod tests {
#[test] #[test]
fn complex() { fn complex() {
// history is 1 // history is 1
let mut jdb = OptionOneDB::new_temp(); let mut jdb = EarlyMergeDB::new_temp();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar"); let bar = jdb.insert(b"bar");
@ -466,7 +466,7 @@ mod tests {
#[test] #[test]
fn fork() { fn fork() {
// history is 1 // history is 1
let mut jdb = OptionOneDB::new_temp(); let mut jdb = EarlyMergeDB::new_temp();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar"); let bar = jdb.insert(b"bar");
@ -494,7 +494,7 @@ mod tests {
#[test] #[test]
fn overwrite() { fn overwrite() {
// history is 1 // history is 1
let mut jdb = OptionOneDB::new_temp(); let mut jdb = EarlyMergeDB::new_temp();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -513,7 +513,7 @@ mod tests {
#[test] #[test]
fn fork_same_key() { fn fork_same_key() {
// history is 1 // history is 1
let mut jdb = OptionOneDB::new_temp(); let mut jdb = EarlyMergeDB::new_temp();
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
@ -535,7 +535,7 @@ mod tests {
let bar = H256::random(); let bar = H256::random();
let foo = { let foo = {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.emplace(bar.clone(), b"bar".to_vec()); jdb.emplace(bar.clone(), b"bar".to_vec());
@ -544,13 +544,13 @@ mod tests {
}; };
{ {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
jdb.remove(&foo); jdb.remove(&foo);
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap(); jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
} }
{ {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
assert!(jdb.exists(&bar)); assert!(jdb.exists(&bar));
jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap(); jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap();
@ -564,7 +564,7 @@ mod tests {
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let foo = { let foo = {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -578,7 +578,7 @@ mod tests {
}; };
{ {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
jdb.remove(&foo); jdb.remove(&foo);
jdb.commit(3, &b"3".sha3(), Some((2, b"2".sha3()))).unwrap(); jdb.commit(3, &b"3".sha3(), Some((2, b"2".sha3()))).unwrap();
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
@ -593,7 +593,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let (foo, bar, baz) = { let (foo, bar, baz) = {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar"); let bar = jdb.insert(b"bar");
@ -608,7 +608,7 @@ mod tests {
}; };
{ {
let mut jdb = OptionOneDB::new(dir.to_str().unwrap()); let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap(); jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap();
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
assert!(!jdb.exists(&baz)); assert!(!jdb.exists(&baz));

View File

@ -21,8 +21,8 @@ use common::*;
/// Export the journaldb module. /// Export the journaldb module.
pub mod traits; pub mod traits;
mod archivedb; mod archivedb;
mod optiononedb; mod earlymergedb;
mod overlay; mod overlayrecentdb;
/// Export the JournalDB trait. /// Export the JournalDB trait.
pub use self::traits::JournalDB; pub use self::traits::JournalDB;
@ -73,8 +73,8 @@ impl fmt::Display for Algorithm {
pub fn new(path: &str, algorithm: Algorithm) -> Box<JournalDB> { pub fn new(path: &str, algorithm: Algorithm) -> Box<JournalDB> {
match algorithm { match algorithm {
Algorithm::Archive => Box::new(archivedb::ArchiveDB::new(path)), Algorithm::Archive => Box::new(archivedb::ArchiveDB::new(path)),
Algorithm::EarlyMerge => Box::new(optiononedb::OptionOneDB::new(path)), Algorithm::EarlyMerge => Box::new(earlymergedb::EarlyMergeDB::new(path)),
Algorithm::OverlayRecent => Box::new(overlay::JournalOverlayDB::new(path)), Algorithm::OverlayRecent => Box::new(overlayrecentdb::OverlayRecentDB::new(path)),
_ => unimplemented!(), _ => unimplemented!(),
} }
} }

View File

@ -56,7 +56,7 @@ use super::JournalDB;
/// the removed key is not present in the history overlay. /// the removed key is not present in the history overlay.
/// 7. Delete ancient record from memory and disk. /// 7. Delete ancient record from memory and disk.
/// ///
pub struct JournalOverlayDB { pub struct OverlayRecentDB {
transaction_overlay: MemoryDB, transaction_overlay: MemoryDB,
backing: Arc<Database>, backing: Arc<Database>,
journal_overlay: Arc<RwLock<JournalOverlay>>, journal_overlay: Arc<RwLock<JournalOverlay>>,
@ -82,9 +82,9 @@ impl HeapSizeOf for JournalEntry {
} }
} }
impl Clone for JournalOverlayDB { impl Clone for OverlayRecentDB {
fn clone(&self) -> JournalOverlayDB { fn clone(&self) -> OverlayRecentDB {
JournalOverlayDB { OverlayRecentDB {
transaction_overlay: MemoryDB::new(), transaction_overlay: MemoryDB::new(),
backing: self.backing.clone(), backing: self.backing.clone(),
journal_overlay: self.journal_overlay.clone(), journal_overlay: self.journal_overlay.clone(),
@ -98,14 +98,14 @@ const VERSION_KEY : [u8; 12] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0
const DB_VERSION : u32 = 0x200 + 3; const DB_VERSION : u32 = 0x200 + 3;
const PADDING : [u8; 10] = [ 0u8; 10 ]; const PADDING : [u8; 10] = [ 0u8; 10 ];
impl JournalOverlayDB { impl OverlayRecentDB {
/// Create a new instance from file /// Create a new instance from file
pub fn new(path: &str) -> JournalOverlayDB { pub fn new(path: &str) -> OverlayRecentDB {
Self::from_prefs(path) Self::from_prefs(path)
} }
/// Create a new instance from file /// Create a new instance from file
pub fn from_prefs(path: &str) -> JournalOverlayDB { pub fn from_prefs(path: &str) -> OverlayRecentDB {
let opts = DatabaseConfig { let opts = DatabaseConfig {
prefix_size: Some(12) //use 12 bytes as prefix, this must match account_db prefix prefix_size: Some(12) //use 12 bytes as prefix, this must match account_db prefix
}; };
@ -121,8 +121,8 @@ impl JournalOverlayDB {
backing.put(&VERSION_KEY, &encode(&DB_VERSION)).expect("Error writing version to database"); backing.put(&VERSION_KEY, &encode(&DB_VERSION)).expect("Error writing version to database");
} }
let journal_overlay = Arc::new(RwLock::new(JournalOverlayDB::read_overlay(&backing))); let journal_overlay = Arc::new(RwLock::new(OverlayRecentDB::read_overlay(&backing)));
JournalOverlayDB { OverlayRecentDB {
transaction_overlay: MemoryDB::new(), transaction_overlay: MemoryDB::new(),
backing: Arc::new(backing), backing: Arc::new(backing),
journal_overlay: journal_overlay, journal_overlay: journal_overlay,
@ -131,7 +131,7 @@ impl JournalOverlayDB {
/// Create a new instance with an anonymous temporary database. /// Create a new instance with an anonymous temporary database.
#[cfg(test)] #[cfg(test)]
pub fn new_temp() -> JournalOverlayDB { pub fn new_temp() -> OverlayRecentDB {
let mut dir = env::temp_dir(); let mut dir = env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
Self::new(dir.to_str().unwrap()) Self::new(dir.to_str().unwrap())
@ -196,7 +196,7 @@ impl JournalOverlayDB {
} }
} }
impl JournalDB for JournalOverlayDB { impl JournalDB for OverlayRecentDB {
fn spawn(&self) -> Box<JournalDB> { fn spawn(&self) -> Box<JournalDB> {
Box::new(self.clone()) Box::new(self.clone())
} }
@ -303,7 +303,7 @@ impl JournalDB for JournalOverlayDB {
} }
impl HashDB for JournalOverlayDB { impl HashDB for OverlayRecentDB {
fn keys(&self) -> HashMap<H256, i32> { fn keys(&self) -> HashMap<H256, i32> {
let mut ret: HashMap<H256, i32> = HashMap::new(); let mut ret: HashMap<H256, i32> = HashMap::new();
for (key, _) in self.backing.iter() { for (key, _) in self.backing.iter() {
@ -367,7 +367,7 @@ mod tests {
#[test] #[test]
fn insert_same_in_fork() { fn insert_same_in_fork() {
// history is 1 // history is 1
let mut jdb = JournalOverlayDB::new_temp(); let mut jdb = OverlayRecentDB::new_temp();
let x = jdb.insert(b"X"); let x = jdb.insert(b"X");
jdb.commit(1, &b"1".sha3(), None).unwrap(); jdb.commit(1, &b"1".sha3(), None).unwrap();
@ -397,7 +397,7 @@ mod tests {
#[test] #[test]
fn long_history() { fn long_history() {
// history is 3 // history is 3
let mut jdb = JournalOverlayDB::new_temp(); let mut jdb = OverlayRecentDB::new_temp();
let h = jdb.insert(b"foo"); let h = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
@ -420,7 +420,7 @@ mod tests {
#[test] #[test]
fn complex() { fn complex() {
// history is 1 // history is 1
let mut jdb = JournalOverlayDB::new_temp(); let mut jdb = OverlayRecentDB::new_temp();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar"); let bar = jdb.insert(b"bar");
@ -463,7 +463,7 @@ mod tests {
#[test] #[test]
fn fork() { fn fork() {
// history is 1 // history is 1
let mut jdb = JournalOverlayDB::new_temp(); let mut jdb = OverlayRecentDB::new_temp();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar"); let bar = jdb.insert(b"bar");
@ -495,7 +495,7 @@ mod tests {
#[test] #[test]
fn overwrite() { fn overwrite() {
// history is 1 // history is 1
let mut jdb = JournalOverlayDB::new_temp(); let mut jdb = OverlayRecentDB::new_temp();
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -520,7 +520,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
@ -548,7 +548,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
@ -576,7 +576,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
@ -614,7 +614,7 @@ mod tests {
let bar = H256::random(); let bar = H256::random();
let foo = { let foo = {
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.emplace(bar.clone(), b"bar".to_vec()); jdb.emplace(bar.clone(), b"bar".to_vec());
@ -624,14 +624,14 @@ mod tests {
}; };
{ {
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.remove(&foo); jdb.remove(&foo);
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap(); jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
} }
{ {
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
assert!(jdb.exists(&bar)); assert!(jdb.exists(&bar));
jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap(); jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap();
@ -646,7 +646,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 4 // history is 4
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
@ -675,7 +675,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 4 // history is 4
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
@ -724,7 +724,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap(); jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
@ -755,7 +755,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 4 // history is 4
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -795,7 +795,7 @@ mod tests {
let foo = b"foo".sha3(); let foo = b"foo".sha3();
{ {
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
jdb.insert(b"foo"); jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap(); jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -816,7 +816,7 @@ mod tests {
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
// incantation to reopen the db // incantation to reopen the db
}; { let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); }; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.remove(&foo); jdb.remove(&foo);
jdb.commit(4, &b"4".sha3(), Some((2, b"2".sha3()))).unwrap(); jdb.commit(4, &b"4".sha3(), Some((2, b"2".sha3()))).unwrap();
@ -824,14 +824,14 @@ mod tests {
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
// incantation to reopen the db // incantation to reopen the db
}; { let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); }; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.commit(5, &b"5".sha3(), Some((3, b"3".sha3()))).unwrap(); jdb.commit(5, &b"5".sha3(), Some((3, b"3".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));
// incantation to reopen the db // incantation to reopen the db
}; { let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); }; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.commit(6, &b"6".sha3(), Some((4, b"4".sha3()))).unwrap(); jdb.commit(6, &b"6".sha3(), Some((4, b"4".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
@ -844,7 +844,7 @@ mod tests {
let mut dir = ::std::env::temp_dir(); let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex()); dir.push(H32::random().hex());
let (foo, bar, baz) = { let (foo, bar, baz) = {
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
// history is 1 // history is 1
let foo = jdb.insert(b"foo"); let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar"); let bar = jdb.insert(b"bar");
@ -862,7 +862,7 @@ mod tests {
}; };
{ {
let mut jdb = JournalOverlayDB::new(dir.to_str().unwrap()); let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap(); jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs()); assert!(jdb.can_reconstruct_refs());
assert!(jdb.exists(&foo)); assert!(jdb.exists(&foo));