Skip to content

Commit

Permalink
fix(electrum): fixed sync functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
LagginTimes authored and evanlinjin committed May 7, 2024
1 parent f1c013a commit fba125f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions crates/electrum/src/electrum_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<E: ElectrumApi> ElectrumExt for E {
let full_scan_req = FullScanRequest::from_chain_tip(request.chain_tip.clone())
.cache_txs(request.tx_cache)
.set_spks_for_keychain((), request.spks.enumerate().map(|(i, spk)| (i as u32, spk)));
let full_scan_res = self.full_scan(full_scan_req, usize::MAX, batch_size)?;
let mut full_scan_res = self.full_scan(full_scan_req, usize::MAX, batch_size)?;

let (tip, _) = construct_update_tip(self, request.chain_tip)?;
let cps = tip
Expand All @@ -156,9 +156,20 @@ impl<E: ElectrumApi> ElectrumExt for E {
.map(|cp| (cp.height(), cp))
.collect::<BTreeMap<u32, CheckPoint>>();

let mut tx_graph = TxGraph::<ConfirmationHeightAnchor>::default();
populate_with_txids(self, &cps, &mut tx_cache, &mut tx_graph, request.txids)?;
populate_with_outpoints(self, &cps, &mut tx_cache, &mut tx_graph, request.outpoints)?;
populate_with_txids(
self,
&cps,
&mut tx_cache,
&mut full_scan_res.graph_update,
request.txids,
)?;
populate_with_outpoints(
self,
&cps,
&mut tx_cache,
&mut full_scan_res.graph_update,
request.outpoints,
)?;

Ok(SyncResult {
chain_update: full_scan_res.chain_update,
Expand Down

0 comments on commit fba125f

Please sign in to comment.