Skip to content

Commit c761103

Browse files
committed
refactor(esplora_ext): rename scan_txs to scan and scan_txs_with_keychains to scan_with_keychain
1 parent 5bf7725 commit c761103

File tree

7 files changed

+28
-32
lines changed

7 files changed

+28
-32
lines changed

crates/esplora/src/async_ext.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait EsploraAsyncExt {
4848
/// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
4949
/// parallel.
5050
#[allow(clippy::result_large_err)]
51-
async fn scan_txs_with_keychains<K: Ord + Clone + Send>(
51+
async fn scan_with_keychain<K: Ord + Clone + Send>(
5252
&self,
5353
keychain_spks: BTreeMap<
5454
K,
@@ -60,18 +60,18 @@ pub trait EsploraAsyncExt {
6060
parallel_requests: usize,
6161
) -> Result<(TxGraph<ConfirmationTimeHeightAnchor>, BTreeMap<K, u32>), Error>;
6262

63-
/// Convenience method to call [`scan_txs_with_keychains`] without requiring a keychain.
63+
/// Convenience method to call [`scan_with_keychain`] without requiring a keychain.
6464
///
65-
/// [`scan_txs_with_keychains`]: EsploraAsyncExt::scan_txs_with_keychains
65+
/// [`scan_with_keychain`]: EsploraAsyncExt::scan_with_keychain
6666
#[allow(clippy::result_large_err)]
67-
async fn scan_txs(
67+
async fn scan(
6868
&self,
6969
misc_spks: impl IntoIterator<IntoIter = impl Iterator<Item = ScriptBuf> + Send> + Send,
7070
txids: impl IntoIterator<IntoIter = impl Iterator<Item = Txid> + Send> + Send,
7171
outpoints: impl IntoIterator<IntoIter = impl Iterator<Item = OutPoint> + Send> + Send,
7272
parallel_requests: usize,
7373
) -> Result<TxGraph<ConfirmationTimeHeightAnchor>, Error> {
74-
self.scan_txs_with_keychains(
74+
self.scan_with_keychain(
7575
[(
7676
(),
7777
misc_spks
@@ -199,7 +199,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
199199
})
200200
}
201201

202-
async fn scan_txs_with_keychains<K: Ord + Clone + Send>(
202+
async fn scan_with_keychain<K: Ord + Clone + Send>(
203203
&self,
204204
keychain_spks: BTreeMap<
205205
K,

crates/esplora/src/blocking_ext.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub trait EsploraExt {
4646
/// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
4747
/// parallel.
4848
#[allow(clippy::result_large_err)]
49-
fn scan_txs_with_keychains<K: Ord + Clone>(
49+
fn scan_with_keychain<K: Ord + Clone>(
5050
&self,
5151
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
5252
txids: impl IntoIterator<Item = Txid>,
@@ -55,18 +55,18 @@ pub trait EsploraExt {
5555
parallel_requests: usize,
5656
) -> Result<(TxGraph<ConfirmationTimeHeightAnchor>, BTreeMap<K, u32>), Error>;
5757

58-
/// Convenience method to call [`scan_txs_with_keychains`] without requiring a keychain.
58+
/// Convenience method to call [`scan_with_keychain`] without requiring a keychain.
5959
///
60-
/// [`scan_txs_with_keychains`]: EsploraExt::scan_txs_with_keychains
60+
/// [`scan_with_keychain`]: EsploraExt::scan_with_keychain
6161
#[allow(clippy::result_large_err)]
62-
fn scan_txs(
62+
fn scan(
6363
&self,
6464
misc_spks: impl IntoIterator<Item = ScriptBuf>,
6565
txids: impl IntoIterator<Item = Txid>,
6666
outpoints: impl IntoIterator<Item = OutPoint>,
6767
parallel_requests: usize,
6868
) -> Result<TxGraph<ConfirmationTimeHeightAnchor>, Error> {
69-
self.scan_txs_with_keychains(
69+
self.scan_with_keychain(
7070
[(
7171
(),
7272
misc_spks
@@ -190,7 +190,7 @@ impl EsploraExt for esplora_client::BlockingClient {
190190
})
191191
}
192192

193-
fn scan_txs_with_keychains<K: Ord + Clone>(
193+
fn scan_with_keychain<K: Ord + Clone>(
194194
&self,
195195
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
196196
txids: impl IntoIterator<Item = Txid>,

crates/esplora/tests/async_ext.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> {
101101

102102
let graph_update = env
103103
.client
104-
.scan_txs(
104+
.scan(
105105
misc_spks.into_iter(),
106106
vec![].into_iter(),
107107
vec![].into_iter(),
@@ -168,7 +168,7 @@ pub async fn test_async_update_tx_graph_gap_limit() -> anyhow::Result<()> {
168168
// will.
169169
let (graph_update, active_indices) = env
170170
.client
171-
.scan_txs_with_keychains(
171+
.scan_with_keychain(
172172
keychains.clone(),
173173
vec![].into_iter(),
174174
vec![].into_iter(),
@@ -180,7 +180,7 @@ pub async fn test_async_update_tx_graph_gap_limit() -> anyhow::Result<()> {
180180
assert!(active_indices.is_empty());
181181
let (graph_update, active_indices) = env
182182
.client
183-
.scan_txs_with_keychains(
183+
.scan_with_keychain(
184184
keychains.clone(),
185185
vec![].into_iter(),
186186
vec![].into_iter(),
@@ -211,7 +211,7 @@ pub async fn test_async_update_tx_graph_gap_limit() -> anyhow::Result<()> {
211211
// The last active indice won't be updated in the first case but will in the second one.
212212
let (graph_update, active_indices) = env
213213
.client
214-
.scan_txs_with_keychains(
214+
.scan_with_keychain(
215215
keychains.clone(),
216216
vec![].into_iter(),
217217
vec![].into_iter(),
@@ -225,7 +225,7 @@ pub async fn test_async_update_tx_graph_gap_limit() -> anyhow::Result<()> {
225225
assert_eq!(active_indices[&0], 3);
226226
let (graph_update, active_indices) = env
227227
.client
228-
.scan_txs_with_keychains(keychains, vec![].into_iter(), vec![].into_iter(), 5, 1)
228+
.scan_with_keychain(keychains, vec![].into_iter(), vec![].into_iter(), 5, 1)
229229
.await?;
230230
let txs: HashSet<_> = graph_update.full_txs().map(|tx| tx.txid).collect();
231231
assert_eq!(txs.len(), 2);

crates/esplora/tests/blocking_ext.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> {
9999
sleep(Duration::from_millis(10))
100100
}
101101

102-
let graph_update = env.client.scan_txs(
102+
let graph_update = env.client.scan(
103103
misc_spks.into_iter(),
104104
vec![].into_iter(),
105105
vec![].into_iter(),
@@ -164,7 +164,7 @@ pub fn test_update_tx_graph_gap_limit() -> anyhow::Result<()> {
164164

165165
// A scan with a gap limit of 2 won't find the transaction, but a scan with a gap limit of 3
166166
// will.
167-
let (graph_update, active_indices) = env.client.scan_txs_with_keychains(
167+
let (graph_update, active_indices) = env.client.scan_with_keychain(
168168
keychains.clone(),
169169
vec![].into_iter(),
170170
vec![].into_iter(),
@@ -173,7 +173,7 @@ pub fn test_update_tx_graph_gap_limit() -> anyhow::Result<()> {
173173
)?;
174174
assert!(graph_update.full_txs().next().is_none());
175175
assert!(active_indices.is_empty());
176-
let (graph_update, active_indices) = env.client.scan_txs_with_keychains(
176+
let (graph_update, active_indices) = env.client.scan_with_keychain(
177177
keychains.clone(),
178178
vec![].into_iter(),
179179
vec![].into_iter(),
@@ -201,7 +201,7 @@ pub fn test_update_tx_graph_gap_limit() -> anyhow::Result<()> {
201201

202202
// A scan with gap limit 4 won't find the second transaction, but a scan with gap limit 5 will.
203203
// The last active indice won't be updated in the first case but will in the second one.
204-
let (graph_update, active_indices) = env.client.scan_txs_with_keychains(
204+
let (graph_update, active_indices) = env.client.scan_with_keychain(
205205
keychains.clone(),
206206
vec![].into_iter(),
207207
vec![].into_iter(),
@@ -212,13 +212,9 @@ pub fn test_update_tx_graph_gap_limit() -> anyhow::Result<()> {
212212
assert_eq!(txs.len(), 1);
213213
assert!(txs.contains(&txid_4th_addr));
214214
assert_eq!(active_indices[&0], 3);
215-
let (graph_update, active_indices) = env.client.scan_txs_with_keychains(
216-
keychains,
217-
vec![].into_iter(),
218-
vec![].into_iter(),
219-
5,
220-
1,
221-
)?;
215+
let (graph_update, active_indices) =
216+
env.client
217+
.scan_with_keychain(keychains, vec![].into_iter(), vec![].into_iter(), 5, 1)?;
222218
let txs: HashSet<_> = graph_update.full_txs().map(|tx| tx.txid).collect();
223219
assert_eq!(txs.len(), 2);
224220
assert!(txs.contains(&txid_4th_addr) && txs.contains(&txid_last_addr));

example-crates/example_esplora/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn main() -> anyhow::Result<()> {
188188
// represents the last active spk derivation indices of keychains
189189
// (`keychain_indices_update`).
190190
let (graph_update, last_active_indices) = client
191-
.scan_txs_with_keychains(
191+
.scan_with_keychain(
192192
keychain_spks,
193193
core::iter::empty(),
194194
core::iter::empty(),
@@ -312,7 +312,7 @@ fn main() -> anyhow::Result<()> {
312312
}
313313

314314
let graph_update =
315-
client.scan_txs(spks, txids, outpoints, scan_options.parallel_requests)?;
315+
client.scan(spks, txids, outpoints, scan_options.parallel_requests)?;
316316

317317
graph.lock().unwrap().apply_update(graph_update)
318318
}

example-crates/wallet_esplora_async/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async fn main() -> Result<(), anyhow::Error> {
5454
})
5555
.collect();
5656
let (update_graph, last_active_indices) = client
57-
.scan_txs_with_keychains(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)
57+
.scan_with_keychain(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)
5858
.await?;
5959
let missing_heights = update_graph.missing_heights(wallet.local_chain());
6060
let chain_update = client.update_local_chain(prev_tip, missing_heights).await?;

example-crates/wallet_esplora_blocking/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn main() -> Result<(), anyhow::Error> {
5454
.collect();
5555

5656
let (update_graph, last_active_indices) =
57-
client.scan_txs_with_keychains(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)?;
57+
client.scan_with_keychain(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)?;
5858
let missing_heights = update_graph.missing_heights(wallet.local_chain());
5959
let chain_update = client.update_local_chain(prev_tip, missing_heights)?;
6060
let update = Update {

0 commit comments

Comments
 (0)