Skip to content

Commit 59fc1b3

Browse files
Merge #1070: Rename methods of esplora ext
2090021 refactor: rename methods in EsploraExt and EsploraExtAsync (Vladimir Fomene) Pull request description: ### Description This PR fixes #1058. Built on top of #1040 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [ ] I've added docs for the new feature ACKs for top commit: realeinherjar: ACK 2090021 danielabrozzoni: ACK 2090021 - code looks good, `example_esplora` and `wallet_esplora_blocking` work just fine. Tree-SHA512: 5b5285aaa67a0c4e8174e480cceec7d934ec04a74d81740e1c82f6b8673c3e3d9c676dc43257a170320089efe2d3cb0d33123b4a395fc3e7fec63f85bdf70c79
2 parents 2867e88 + 2090021 commit 59fc1b3

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
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 update_tx_graph<K: Ord + Clone + Send>(
51+
async fn scan_txs_with_keychains<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<ConfirmationTimeAnchor>, BTreeMap<K, u32>), Error>;
6262

63-
/// Convenience method to call [`update_tx_graph`] without requiring a keychain.
63+
/// Convenience method to call [`scan_txs_with_keychains`] without requiring a keychain.
6464
///
65-
/// [`update_tx_graph`]: EsploraAsyncExt::update_tx_graph
65+
/// [`scan_txs_with_keychains`]: EsploraAsyncExt::scan_txs_with_keychains
6666
#[allow(clippy::result_large_err)]
67-
async fn update_tx_graph_without_keychain(
67+
async fn scan_txs(
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<ConfirmationTimeAnchor>, Error> {
74-
self.update_tx_graph(
74+
self.scan_txs_with_keychains(
7575
[(
7676
(),
7777
misc_spks
@@ -201,7 +201,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
201201
})
202202
}
203203

204-
async fn update_tx_graph<K: Ord + Clone + Send>(
204+
async fn scan_txs_with_keychains<K: Ord + Clone + Send>(
205205
&self,
206206
keychain_spks: BTreeMap<
207207
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 update_tx_graph<K: Ord + Clone>(
49+
fn scan_txs_with_keychains<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<ConfirmationTimeAnchor>, BTreeMap<K, u32>), Error>;
5757

58-
/// Convenience method to call [`update_tx_graph`] without requiring a keychain.
58+
/// Convenience method to call [`scan_txs_with_keychains`] without requiring a keychain.
5959
///
60-
/// [`update_tx_graph`]: EsploraExt::update_tx_graph
60+
/// [`scan_txs_with_keychains`]: EsploraExt::scan_txs_with_keychains
6161
#[allow(clippy::result_large_err)]
62-
fn update_tx_graph_without_keychain(
62+
fn scan_txs(
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<ConfirmationTimeAnchor>, Error> {
69-
self.update_tx_graph(
69+
self.scan_txs_with_keychains(
7070
[(
7171
(),
7272
misc_spks
@@ -192,7 +192,7 @@ impl EsploraExt for esplora_client::BlockingClient {
192192
})
193193
}
194194

195-
fn update_tx_graph<K: Ord + Clone>(
195+
fn scan_txs_with_keychains<K: Ord + Clone>(
196196
&self,
197197
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
198198
txids: impl IntoIterator<Item = Txid>,

example-crates/example_esplora/src/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn main() -> anyhow::Result<()> {
154154
// represents the last active spk derivation indices of keychains
155155
// (`keychain_indices_update`).
156156
let (graph_update, last_active_indices) = client
157-
.update_tx_graph(
157+
.scan_txs_with_keychains(
158158
keychain_spks,
159159
core::iter::empty(),
160160
core::iter::empty(),
@@ -276,12 +276,8 @@ fn main() -> anyhow::Result<()> {
276276
}
277277
}
278278

279-
let graph_update = client.update_tx_graph_without_keychain(
280-
spks,
281-
txids,
282-
outpoints,
283-
scan_options.parallel_requests,
284-
)?;
279+
let graph_update =
280+
client.scan_txs(spks, txids, outpoints, scan_options.parallel_requests)?;
285281

286282
graph.lock().unwrap().apply_update(graph_update)
287283
}

example-crates/wallet_esplora_async/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5555
})
5656
.collect();
5757
let (update_graph, last_active_indices) = client
58-
.update_tx_graph(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)
58+
.scan_txs_with_keychains(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)
5959
.await?;
6060
let missing_heights = wallet.tx_graph().missing_heights(wallet.local_chain());
6161
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
@@ -55,7 +55,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5555
.collect();
5656

5757
let (update_graph, last_active_indices) =
58-
client.update_tx_graph(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)?;
58+
client.scan_txs_with_keychains(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)?;
5959
let missing_heights = wallet.tx_graph().missing_heights(wallet.local_chain());
6060
let chain_update = client.update_local_chain(prev_tip, missing_heights)?;
6161
let update = WalletUpdate {

0 commit comments

Comments
 (0)