From 7db55592d0e6828b7d2e1c7257f6b8779716c861 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Tue, 3 Dec 2019 20:30:10 +0000 Subject: [PATCH] Bits and Pieces for 3.0.0 beta (#271) * deprecate the V2 Owner API * rustfmt * fix output from scan * fix scan output to be more consistent * rustfmt * updater thread test --- api/src/owner.rs | 6 +++++- api/src/owner_rpc.rs | 4 ++++ controller/tests/updater_thread.rs | 2 +- libwallet/src/api_impl/owner.rs | 3 +-- libwallet/src/internal/scan.rs | 16 +++++----------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/api/src/owner.rs b/api/src/owner.rs index 7f88988b..539e5edb 100644 --- a/api/src/owner.rs +++ b/api/src/owner.rs @@ -1226,12 +1226,16 @@ where start_height: Option, delete_unconfirmed: bool, ) -> Result<(), Error> { + let tx = { + let t = self.status_tx.lock(); + t.clone() + }; owner::scan( self.wallet_inst.clone(), keychain_mask, start_height, delete_unconfirmed, - &None, + &tx, ) } diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index c88b7b28..bd0ada6f 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -67,6 +67,10 @@ pub trait OwnerRpc: Sync + Send { # , false, 4, false, false, false); ``` */ + #[deprecated( + since = "3.0.0", + note = "The V2 Owner API (OwnerRpc) will be removed in grin-wallet 4.0.0. Please migrate to the V3 (OwnerRpcS) API as soon as possible." + )] fn accounts(&self) -> Result, ErrorKind>; /** diff --git a/controller/tests/updater_thread.rs b/controller/tests/updater_thread.rs index 33b85ffe..9f010492 100644 --- a/controller/tests/updater_thread.rs +++ b/controller/tests/updater_thread.rs @@ -98,7 +98,7 @@ fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err thread::sleep(Duration::from_secs(10)); let messages = owner_api.get_updater_messages(1000)?; - assert_eq!(messages.len(), 34); + assert_eq!(messages.len(), 32); owner_api.stop_updater()?; thread::sleep(Duration::from_secs(2)); diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index ef3f7cf7..d4d6139a 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -722,8 +722,7 @@ where let start_index = last_scanned_block.height.saturating_sub(100); if last_scanned_block.height == 0 { - let msg = format!("This wallet's contents has not been initialized with a full chain scan, performing scan now. - This operation may take a while for the first scan, but should be much quicker once the initial scan is done."); + let msg = format!("This wallet has not been scanned against the current chain. Beginning full scan... (this first scan may take a while, but subsequent scans will be much quicker)"); if let Some(ref s) = status_send_channel { let _ = s.send(StatusMessage::FullScanWarn(msg)); } diff --git a/libwallet/src/internal/scan.rs b/libwallet/src/internal/scan.rs index d4fe8e98..13c0ced9 100644 --- a/libwallet/src/internal/scan.rs +++ b/libwallet/src/internal/scan.rs @@ -73,13 +73,6 @@ where K: Keychain + 'a, { let mut wallet_outputs: Vec = Vec::new(); - let msg = format!( - "Scanning {} outputs in the current Grin utxo set", - outputs.len(), - ); - if let Some(ref s) = status_send_channel { - let _ = s.send(StatusMessage::Scanning(msg, percentage_complete)); - } let legacy_builder = proof::LegacyProofBuilder::new(keychain); let builder = proof::ProofBuilder::new(keychain); @@ -161,16 +154,17 @@ where K: Keychain + 'a, { let batch_size = 1000; + let start_index_stat = start_index; let mut start_index = start_index; let mut result_vec: Vec = vec![]; let last_retrieved_return_index; loop { let (highest_index, last_retrieved_index, outputs) = client.get_outputs_by_pmmr_index(start_index, end_index, batch_size)?; - let perc_complete = cmp::min( - ((last_retrieved_index as f64 / highest_index as f64) * 100.0) as u8, - 99, - ); + + let range = highest_index as f64 - start_index_stat as f64; + let progress = last_retrieved_index as f64 - start_index_stat as f64; + let perc_complete = cmp::min(((progress / range) * 100.0) as u8, 99); let msg = format!( "Checking {} outputs, up to index {}. (Highest index: {})",