Skip to content

Commit

Permalink
Bits and Pieces for 3.0.0 beta (mimblewimble#271)
Browse files Browse the repository at this point in the history
* deprecate the V2 Owner API

* rustfmt

* fix output from scan

* fix scan output to be more consistent

* rustfmt

* updater thread test
  • Loading branch information
yeastplume authored Dec 3, 2019
1 parent 29b9222 commit 7db5559
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
6 changes: 5 additions & 1 deletion api/src/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,12 +1226,16 @@ where
start_height: Option<u64>,
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,
)
}

Expand Down
4 changes: 4 additions & 0 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<AcctPathMapping>, ErrorKind>;

/**
Expand Down
2 changes: 1 addition & 1 deletion controller/tests/updater_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions libwallet/src/api_impl/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
16 changes: 5 additions & 11 deletions libwallet/src/internal/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ where
K: Keychain + 'a,
{
let mut wallet_outputs: Vec<OutputResult> = 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);
Expand Down Expand Up @@ -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<OutputResult> = 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: {})",
Expand Down

0 comments on commit 7db5559

Please sign in to comment.