Skip to content

Commit 3eae93e

Browse files
committed
use only our sync
1 parent 3dde460 commit 3eae93e

File tree

4 files changed

+12
-56
lines changed

4 files changed

+12
-56
lines changed

src/bindgen/wallet.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,32 +126,8 @@ impl WebWallet {
126126
self.inner.suggest_scan_ranges().await
127127
}
128128

129-
/// Synchronize the wallet with the blockchain up to the tip using zcash_client_backend's algo
130-
pub async fn sync(&self) -> Result<(), Error> {
131-
assert!(!thread::is_web_worker_thread());
132-
133-
let db = self.inner.clone();
134-
135-
let sync_handler = thread::Builder::new()
136-
.name("sync".to_string())
137-
.spawn_async(|| async {
138-
assert!(thread::is_web_worker_thread());
139-
tracing::debug!(
140-
"Current num threads (wasm_thread) {}",
141-
rayon::current_num_threads()
142-
);
143-
144-
let db = db;
145-
db.sync().await.unwrap_throw();
146-
})
147-
.unwrap_throw()
148-
.join_async();
149-
sync_handler.await.unwrap();
150-
Ok(())
151-
}
152-
153129
/// Synchronize the wallet with the blockchain up to the tip using our newest and bestest
154-
pub async fn sync3(&self) -> Result<(), Error> {
130+
pub async fn sync(&self) -> Result<(), Error> {
155131
assert!(!thread::is_web_worker_thread());
156132
tracing::debug!("SYNC 3 Main!!!!");
157133
let db = self.inner.clone();
@@ -166,7 +142,7 @@ impl WebWallet {
166142
);
167143

168144
let db = db;
169-
db.sync3().await.unwrap_throw();
145+
db.sync().await.unwrap_throw();
170146
})
171147
.unwrap_throw()
172148
.join_async();

src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ use wasm_bindgen::prelude::*;
1919
/// The maximum number of checkpoints to store in each shard-tree
2020
pub const PRUNING_DEPTH: usize = 100;
2121

22-
23-
use zcash_client_memory::MemoryWalletDb;
24-
use zcash_primitives::consensus;
25-
2622
#[cfg(feature = "wasm-parallel")]
2723
pub use wasm_bindgen_rayon::init_thread_pool;
2824

@@ -34,5 +30,4 @@ pub fn init_thread_pool(_threads: usize) {}
3430
#[wasm_bindgen]
3531
pub struct BlockRange(pub u32, pub u32);
3632

37-
38-
pub mod sync3;
33+
pub mod sync;

src/sync3/mod.rs renamed to src/sync.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ where
9292
// any shielded scanning, to ensure that we discover any UTXOs between the old
9393
// fully-scanned height and the current chain tip.
9494
// #[cfg(feature = "transparent-inputs")]
95-
let account_ids = db_data.read().await.get_account_ids().map_err(Error::Wallet)?;
96-
for account_id in account_ids
97-
{
95+
let account_ids = db_data
96+
.read()
97+
.await
98+
.get_account_ids()
99+
.map_err(Error::Wallet)?;
100+
for account_id in account_ids {
98101
let start_height = db_data
99102
.read()
100103
.await

src/wallet.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tonic::{
99
};
1010

1111
use crate::error::Error;
12-
use crate::{sync3, BlockRange};
12+
use crate::BlockRange;
1313

1414
use serde::{Serialize, Serializer};
1515
use std::fmt::Debug;
@@ -41,7 +41,6 @@ use zcash_primitives::transaction::fees::zip317::FeeRule;
4141
use zcash_primitives::transaction::TxId;
4242
use zcash_proofs::prover::LocalTxProver;
4343

44-
use zcash_client_backend::sync::run;
4544
const BATCH_SIZE: u32 = 10000;
4645

4746
/// # A Zcash wallet
@@ -224,33 +223,16 @@ where
224223
})?)
225224
}
226225

227-
pub async fn sync3(&self) -> Result<(), Error> {
228-
let mut client = self.client.clone();
229-
// TODO: This should be held in the Wallet struct so we can download in parallel
230-
let db_cache = MemBlockCache::new();
231-
232-
sync3::run(
233-
&mut client,
234-
&self.network.clone(),
235-
&db_cache,
236-
self.db.clone(),
237-
BATCH_SIZE,
238-
)
239-
.await
240-
.map_err(Into::into)
241-
}
242-
243226
pub async fn sync(&self) -> Result<(), Error> {
244227
let mut client = self.client.clone();
245228
// TODO: This should be held in the Wallet struct so we can download in parallel
246229
let db_cache = MemBlockCache::new();
247230

248-
let mut db = self.db.write().await;
249-
run(
231+
crate::sync::run(
250232
&mut client,
251233
&self.network.clone(),
252234
&db_cache,
253-
&mut *db,
235+
self.db.clone(),
254236
BATCH_SIZE,
255237
)
256238
.await

0 commit comments

Comments
 (0)