Skip to content

Commit

Permalink
refactor(electrum_ext): rename scan to scan_with_keychain and scan_wi…
Browse files Browse the repository at this point in the history
…thout_keychain to scan
  • Loading branch information
notmandatory committed Dec 7, 2023
1 parent f741122 commit 5bf7725
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions crates/electrum/src/electrum_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub trait ElectrumExt {
/// The scan for each keychain stops after a gap of `stop_gap` script pubkeys with no associated
/// transactions. `batch_size` specifies the max number of script pubkeys to request for in a
/// single batch request.
fn scan<K: Ord + Clone>(
fn scan_with_keychain<K: Ord + Clone>(
&self,
prev_tip: CheckPoint,
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
Expand All @@ -156,10 +156,10 @@ pub trait ElectrumExt {
batch_size: usize,
) -> Result<(ElectrumUpdate, BTreeMap<K, u32>), Error>;

/// Convenience method to call [`scan`] without requiring a keychain.
/// Convenience method to call [`scan_with_keychain`] without requiring a keychain.
///
/// [`scan`]: ElectrumExt::scan
fn scan_without_keychain(
/// [`scan_with_keychain`]: ElectrumExt::scan_with_keychain
fn scan(
&self,
prev_tip: CheckPoint,
misc_spks: impl IntoIterator<Item = ScriptBuf>,
Expand All @@ -172,7 +172,7 @@ pub trait ElectrumExt {
.enumerate()
.map(|(i, spk)| (i as u32, spk));

let (electrum_update, _) = self.scan(
let (electrum_update, _) = self.scan_with_keychain(
prev_tip,
[((), spk_iter)].into(),
txids,
Expand All @@ -186,7 +186,7 @@ pub trait ElectrumExt {
}

impl ElectrumExt for Client {
fn scan<K: Ord + Clone>(
fn scan_with_keychain<K: Ord + Clone>(
&self,
prev_tip: CheckPoint,
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/electrum/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This crate is used for updating structures of the [`bdk_chain`] crate with data from electrum.
//!
//! The star of the show is the [`ElectrumExt::scan`] method, which scans for relevant blockchain
//! The star of the show is the [`ElectrumExt::scan_with_keychain`] method, which scans for relevant blockchain
//! data (via electrum) and outputs updates for [`bdk_chain`] structures as a tuple of form:
//!
//! ([`bdk_chain::local_chain::Update`], [`RelevantTxids`], `keychain_update`)
Expand Down
4 changes: 2 additions & 2 deletions example-crates/example_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn main() -> anyhow::Result<()> {
};

client
.scan(
.scan_with_keychain(
tip,
keychain_spks,
core::iter::empty(),
Expand Down Expand Up @@ -279,7 +279,7 @@ fn main() -> anyhow::Result<()> {
drop((graph, chain));

let electrum_update = client
.scan_without_keychain(tip, spks, txids, outpoints, scan_options.batch_size)
.scan(tip, spks, txids, outpoints, scan_options.batch_size)
.context("scanning the blockchain")?;
(electrum_update, BTreeMap::new())
}
Expand Down
2 changes: 1 addition & 1 deletion example-crates/wallet_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() -> Result<(), anyhow::Error> {
relevant_txids,
},
keychain_update,
) = client.scan(prev_tip, keychain_spks, None, None, STOP_GAP, BATCH_SIZE)?;
) = client.scan_with_keychain(prev_tip, keychain_spks, None, None, STOP_GAP, BATCH_SIZE)?;

println!();

Expand Down

0 comments on commit 5bf7725

Please sign in to comment.