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

Method sync

src/app.rs:140–176  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

138 // Run a single sync 'tick'
139 #[allow(clippy::option_map_unit_fn)]
140 pub fn sync(&self) -> Result<Vec<IndexChange>> {
141 // Synchronize new blocks/transactions
142 let updates = self.indexer.write().unwrap().sync()?;
143
144 // Emit updates
145 if !updates.is_empty() {
146 #[cfg(feature = "electrum")]
147 self.electrum
148 .as_ref()
149 .map(|electrum| electrum.send_updates(&updates));
150
151 #[cfg(feature = "http")]
152 self.http.as_ref().map(|http| http.send_updates(&updates));
153
154 #[cfg(feature = "webhooks")]
155 self.webhook
156 .as_ref()
157 .map(|webhook| webhook.send_updates(&updates));
158 }
159
160 // Try running 'pruneblockchain' until it succeeds, then stop
161 /*
162 if let Some(prune_until) = self.config.prune_until {
163 // XXX run less?
164 if self.pruning_pending.get() {
165 if let Ok(pruned) = self.query.rpc().prune_blockchain(prune_until) {
166 info!(target: LT, "Successfully pruned up to height {}", pruned);
167 self.pruning_pending.set(false);
168 } // will fail if the current tip is earlier than `prune_until`
169 }
170 }*/
171
172 // Try pruning the chain (when 'prune-until' is set)
173 self.try_prune()?;
174
175 Ok(updates)
176 }
177
178 /// Start a sync loop blocking the current thread
179 pub fn sync_loop(&self, shutdown_rx: Option<mpsc::Receiver<()>>) {

Callers 1

sync_loopMethod · 0.45

Calls 2

try_pruneMethod · 0.80
send_updatesMethod · 0.45

Tested by

no test coverage detected