Skip to content

Commit

Permalink
Remove duplicate LMDB wallet backend code (mimblewimble#101)
Browse files Browse the repository at this point in the history
* remove leftover wallet lmdb code

* rustfmt
  • Loading branch information
yeastplume authored May 11, 2019
1 parent 50396a0 commit 6c78d23
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 588 deletions.
31 changes: 21 additions & 10 deletions impls/src/backends/lmdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ use crate::store::{self, option_to_not_found, to_key, to_key_u64};

use crate::core::core::Transaction;
use crate::core::{global, ser};
use crate::libwallet::types::*;
use crate::libwallet::{internal, Error, ErrorKind};
use crate::libwallet::{check_repair, restore};
use crate::libwallet::{
AcctPathMapping, Context, Error, ErrorKind, NodeClient, OutputData, TxLogEntry, WalletBackend,
WalletOutputBatch,
};
use crate::util;
use crate::util::secp::constants::SECRET_KEY_SIZE;
use crate::util::ZeroingString;
Expand Down Expand Up @@ -235,7 +238,7 @@ where
}

fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = OutputData> + 'a> {
Box::new(self.db.iter(&[OUTPUT_PREFIX]).unwrap())
Box::new(self.db.iter(&[OUTPUT_PREFIX]).unwrap().map(|o| o.1))
}

fn get_tx_log_entry(&self, u: &Uuid) -> Result<Option<TxLogEntry>, Error> {
Expand All @@ -244,7 +247,7 @@ where
}

fn tx_log_iter<'a>(&'a self) -> Box<dyn Iterator<Item = TxLogEntry> + 'a> {
Box::new(self.db.iter(&[TX_LOG_ENTRY_PREFIX]).unwrap())
Box::new(self.db.iter(&[TX_LOG_ENTRY_PREFIX]).unwrap().map(|o| o.1))
}

fn get_private_context(&mut self, slate_id: &[u8]) -> Result<Context, Error> {
Expand All @@ -265,7 +268,12 @@ where
}

fn acct_path_iter<'a>(&'a self) -> Box<dyn Iterator<Item = AcctPathMapping> + 'a> {
Box::new(self.db.iter(&[ACCOUNT_PATH_MAPPING_PREFIX]).unwrap())
Box::new(
self.db
.iter(&[ACCOUNT_PATH_MAPPING_PREFIX])
.unwrap()
.map(|o| o.1),
)
}

fn get_acct_path(&self, label: String) -> Result<Option<AcctPathMapping>, Error> {
Expand Down Expand Up @@ -346,12 +354,12 @@ where
}

fn restore(&mut self) -> Result<(), Error> {
internal::restore::restore(self).context(ErrorKind::Restore)?;
restore(self).context(ErrorKind::Restore)?;
Ok(())
}

fn check_repair(&mut self, delete_unconfirmed: bool) -> Result<(), Error> {
internal::restore::check_repair(self, delete_unconfirmed).context(ErrorKind::Restore)?;
check_repair(self, delete_unconfirmed).context(ErrorKind::Restore)?;
Ok(())
}
}
Expand Down Expand Up @@ -411,7 +419,8 @@ where
.as_ref()
.unwrap()
.iter(&[OUTPUT_PREFIX])
.unwrap(),
.unwrap()
.map(|o| o.1),
)
}

Expand Down Expand Up @@ -449,7 +458,8 @@ where
.as_ref()
.unwrap()
.iter(&[TX_LOG_ENTRY_PREFIX])
.unwrap(),
.unwrap()
.map(|o| o.1),
)
}

Expand Down Expand Up @@ -518,7 +528,8 @@ where
.as_ref()
.unwrap()
.iter(&[ACCOUNT_PATH_MAPPING_PREFIX])
.unwrap(),
.unwrap()
.map(|o| o.1),
)
}

Expand Down
2 changes: 1 addition & 1 deletion impls/src/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

mod lmdb;

pub use self::lmdb::LMDBBackend;
pub use self::lmdb::{wallet_db_exists, LMDBBackend};
4 changes: 2 additions & 2 deletions impls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use grin_wallet_util::grin_util as util;
extern crate grin_wallet_config as config;

mod adapters;
mod backends;
mod error;
mod lmdb_wallet;
mod node_clients;
mod seed;
pub mod test_framework;
Expand All @@ -42,8 +42,8 @@ pub use crate::adapters::{
FileWalletCommAdapter, HTTPWalletCommAdapter, KeybaseWalletCommAdapter, NullWalletCommAdapter,
WalletCommAdapter,
};
pub use crate::backends::{wallet_db_exists, LMDBBackend};
pub use crate::error::{Error, ErrorKind};
pub use crate::lmdb_wallet::{wallet_db_exists, LMDBBackend};
pub use crate::node_clients::HTTPNodeClient;
pub use crate::seed::{EncryptedWalletSeed, WalletSeed, SEED_FILE};

Expand Down
Loading

0 comments on commit 6c78d23

Please sign in to comment.