MCPcopy Create free account
hub / github.com/bwt-dev/bwt / initial_sync

Method initial_sync

src/indexer.rs:54–84  ·  view source on GitHub ↗

continue to sync transactions and import addresses (with rescan) until no more new addresses need to be imported. the initial sync does not collect the Changelog and does not emit updates.

(&mut self, progress_tx: Option<mpsc::Sender<Progress>>)

Source from the content-addressed store, hash-verified

52 // continue to sync transactions and import addresses (with rescan) until no more new addresses
53 // need to be imported. the initial sync does not collect the Changelog and does not emit updates.
54 pub fn initial_sync(&mut self, progress_tx: Option<mpsc::Sender<Progress>>) -> Result<()> {
55 let timer = time::Instant::now();
56
57 debug!("starting initial sync");
58 self.watcher.check_imports(&self.rpc)?;
59
60 let mut changelog = Changelog::new(false);
61 let mut synced_tip;
62
63 let shutdown_progress_thread = spawn_send_progress_thread(self.rpc.clone(), progress_tx);
64
65 while {
66 synced_tip = self.sync_transactions(true, &mut changelog)?;
67 self.watcher.do_imports(&self.rpc, /*rescan=*/ true)?
68 } { /* do while */ }
69
70 shutdown_progress_thread.send(()).ok();
71
72 self.sync_mempool(/*force_refresh=*/ true);
73
74 let stats = self.store.stats();
75 info!(
76 "completed initial sync in {:?} up to height {} (total {} transactions and {} addresses)",
77 timer.elapsed(),
78 synced_tip.0,
79 stats.transaction_count,
80 stats.scripthash_count,
81 );
82 self.tip = Some(synced_tip);
83 Ok(())
84 }
85
86 // initiate a regular sync to catch up with updates and import new addresses (no rescan)
87 pub fn sync(&mut self) -> Result<Vec<IndexChange>> {

Callers 1

bootMethod · 0.80

Calls 6

check_importsMethod · 0.80
sync_transactionsMethod · 0.80
do_importsMethod · 0.80
sync_mempoolMethod · 0.80
statsMethod · 0.80

Tested by

no test coverage detected