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>>)
| 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>> { |
no test coverage detected