diff --git a/Cargo.lock b/Cargo.lock index acf44e78..9f820cb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3564,7 +3564,7 @@ dependencies = [ [[package]] name = "zecwallet-cli" -version = "1.7.14" +version = "1.7.15" dependencies = [ "byteorder", "clap", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 441bd0e8..933f3b51 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zecwallet-cli" -version = "1.7.14" +version = "1.7.15" edition = "2018" [dependencies] diff --git a/cli/src/version.rs b/cli/src/version.rs index e8d30180..5d98dbb1 100644 --- a/cli/src/version.rs +++ b/cli/src/version.rs @@ -1 +1 @@ -pub const VERSION: &str = "1.7.14"; +pub const VERSION: &str = "1.7.15"; diff --git a/lib/src/blaze/block_witness_data.rs b/lib/src/blaze/block_witness_data.rs index 99ccc42a..882c7105 100644 --- a/lib/src/blaze/block_witness_data.rs +++ b/lib/src/blaze/block_witness_data.rs @@ -60,7 +60,7 @@ impl BlockAndWitnessData { blocks: Arc::new(RwLock::new(vec![])), existing_blocks: Arc::new(RwLock::new(vec![])), verification_list: Arc::new(RwLock::new(vec![])), - batch_size: 5_000, + batch_size: 1_000, verified_tree: None, sync_status, sapling_activation_height: config.sapling_activation_height, @@ -306,8 +306,10 @@ impl BlockAndWitnessData { let mut last_block_expecting = end_block; while let Some(cb) = rx.recv().await { - // We'll process 25_000 blocks at a time. + // We'll process batch_size (1_000) blocks at a time. + // println!("Recieved block # {}", cb.height); if cb.height % batch_size == 0 { + // println!("Batch size hit at height {} with len {}", cb.height, blks.len()); if !blks.is_empty() { // Add these blocks to the list sync_status.write().await.blocks_done += blks.len() as u64; @@ -345,6 +347,11 @@ impl BlockAndWitnessData { blks.push(BlockData::new(cb)); } + // println!( + // "Final block size at earliest-height {} with len {}", + // earliest_block_height, + // blks.len() + // ); if !blks.is_empty() { // We'll now dispatch these blocks for updating the witness sync_status.write().await.blocks_done += blks.len() as u64; diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index 79858e7b..f21472d0 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -1238,10 +1238,6 @@ impl LightClient

{ /// Start syncing in batches with the max size, so we don't consume memory more than // wha twe can handle. async fn start_sync(&self) -> Result { - // We can only do one sync at a time because we sync blocks in serial order - // If we allow multiple syncs, they'll all get jumbled up. - let _lock = self.sync_lock.lock().await; - // The top of the wallet let last_scanned_height = self.wallet.last_scanned_height().await; @@ -1274,7 +1270,7 @@ impl LightClient

{ // Re-read the last scanned height let last_scanned_height = self.wallet.last_scanned_height().await; - let batch_size = 50_000; + let batch_size = 25_000; let mut latest_block_batches = vec![]; let mut prev = last_scanned_height; @@ -1297,7 +1293,14 @@ impl LightClient

{ let mut res = Err("No batches were run!".to_string()); for (batch_num, batch_latest_block) in latest_block_batches.into_iter().enumerate() { - res = self.start_sync_batch(batch_latest_block, batch_num).await; + { + // We can only do one sync at a time because we sync blocks in serial order + // If we allow multiple syncs, they'll all get jumbled up. + let _lock = self.sync_lock.lock().await; + res = self.start_sync_batch(batch_latest_block, batch_num).await; + } + + self.do_save().await?; if res.is_err() { return res; } diff --git a/lib/src/lightclient/tests.rs b/lib/src/lightclient/tests.rs index 01541735..d1216343 100644 --- a/lib/src/lightclient/tests.rs +++ b/lib/src/lightclient/tests.rs @@ -1,3 +1,6 @@ +use std::fs; +use std::path::Path; + use ff::{Field, PrimeField}; use group::GroupEncoding; use json::JsonValue; @@ -1109,6 +1112,8 @@ async fn recover_at_checkpoint() { ); // 5: Test2: Create a new lightwallet, restoring at checkpoint + 100 + // First remove the old wallet + fs::remove_file(Path::new(config.data_dir.as_ref().unwrap()).join("zecwallet-light-wallet.dat")).unwrap(); let lc = LightClient::test_new(&config, Some(TEST_SEED.to_string()), ckpt_height + 100) .await .unwrap();