Split wallet client trait (#1970)

* complete trait split

* rustfmt
This commit is contained in:
Yeastplume
2018-11-13 13:18:33 +01:00
committed by GitHub
parent 236fe56f60
commit 5a06f5dac7
23 changed files with 545 additions and 344 deletions
+22 -14
View File
@@ -29,7 +29,8 @@ use core::{core, global};
use grin_wallet::libwallet::ErrorKind;
use grin_wallet::{self, controller, display, libwallet};
use grin_wallet::{
HTTPWalletClient, LMDBBackend, WalletBackend, WalletConfig, WalletInst, WalletSeed,
HTTPWalletToNodeClient, HTTPWalletToWalletClient, LMDBBackend, WalletBackend, WalletConfig,
WalletInst, WalletSeed,
};
use keychain;
use servers::start_webwallet_server;
@@ -56,10 +57,13 @@ pub fn instantiate_wallet(
passphrase: &str,
account: &str,
node_api_secret: Option<String>,
) -> Arc<Mutex<WalletInst<HTTPWalletClient, keychain::ExtKeychain>>> {
let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr, node_api_secret);
let mut db_wallet =
LMDBBackend::new(wallet_config.clone(), passphrase, client).unwrap_or_else(|e| {
) -> Arc<Mutex<WalletInst<HTTPWalletToNodeClient, HTTPWalletToWalletClient, keychain::ExtKeychain>>>
{
let client_n =
HTTPWalletToNodeClient::new(&wallet_config.check_node_api_http_addr, node_api_secret);
let client_w = HTTPWalletToWalletClient::new();
let mut db_wallet = LMDBBackend::new(wallet_config.clone(), passphrase, client_n, client_w)
.unwrap_or_else(|e| {
panic!(
"Error creating DB wallet: {} Config: {:?}",
e, wallet_config
@@ -105,15 +109,19 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) -> i
if let ("init", Some(_)) = wallet_args.subcommand() {
WalletSeed::init_file(&wallet_config).expect("Failed to init wallet seed file.");
info!("Wallet seed file created");
let client =
HTTPWalletClient::new(&wallet_config.check_node_api_http_addr, node_api_secret);
let _: LMDBBackend<HTTPWalletClient, keychain::ExtKeychain> =
LMDBBackend::new(wallet_config.clone(), "", client).unwrap_or_else(|e| {
panic!(
"Error creating DB for wallet: {} Config: {:?}",
e, wallet_config
);
});
let client_n =
HTTPWalletToNodeClient::new(&wallet_config.check_node_api_http_addr, node_api_secret);
let client_w = HTTPWalletToWalletClient::new();
let _: LMDBBackend<
HTTPWalletToNodeClient,
HTTPWalletToWalletClient,
keychain::ExtKeychain,
> = LMDBBackend::new(wallet_config.clone(), "", client_n, client_w).unwrap_or_else(|e| {
panic!(
"Error creating DB for wallet: {} Config: {:?}",
e, wallet_config
);
});
info!("Wallet database backend created");
// give logging thread a moment to catch up
thread::sleep(Duration::from_millis(200));