Support reloading the mempool from disk

This commit is contained in:
Luke Parker
2023-04-14 15:51:43 -04:00
parent c032f66f8a
commit 2e2bc59703
7 changed files with 127 additions and 41 deletions

View File

@@ -29,8 +29,8 @@ pub trait Db: 'static + Send + Sync + Clone + Debug + Get {
}
/// An atomic operation for the in-memory databae.
#[derive(Debug)]
#[must_use]
#[derive(PartialEq, Eq, Debug)]
pub struct MemDbTxn<'a>(&'a MemDb, HashMap<Vec<u8>, Vec<u8>>, HashSet<Vec<u8>>);
impl<'a> Get for MemDbTxn<'a> {
@@ -65,6 +65,13 @@ impl<'a> DbTxn for MemDbTxn<'a> {
#[derive(Clone, Debug)]
pub struct MemDb(Arc<RwLock<HashMap<Vec<u8>, Vec<u8>>>>);
impl PartialEq for MemDb {
fn eq(&self, other: &MemDb) -> bool {
*self.0.read().unwrap() == *other.0.read().unwrap()
}
}
impl Eq for MemDb {}
impl Default for MemDb {
fn default() -> MemDb {
MemDb(Arc::new(RwLock::new(HashMap::new())))