Skip to content

Commit 2a1787b

Browse files
committed
Merge #1746: deps(esplora): bump esplora-client to 0.11.0
90fd1a2 docs(esplora): update README.md (valued mammal) f0e6395 deps(esplora): bump `esplora-client` to 0.11.0 (valued mammal) Pull request description: Update `bdk_esplora` to depend on esplora-client 0.11.0 ### Notes to the reviewers bitcoindevkit/rust-esplora-client#103 added a generic type parameter to `AsyncClient` representing a user-defined `Sleeper` and that change is reflected here in order to call the underlying API methods. We also add a new build feature "tokio" that enables the corresponding feature in rust-esplora-client. closes #1742 ### Changelog notice `bdk_esplora`: Bump `esplora-client` to 0.11.0 ### 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 * [x] This pull request breaks the existing API * [x] I'm linking the issue being fixed by this PR ACKs for top commit: notmandatory: tACK 90fd1a2 oleonardolima: ACK 90fd1a2 Tree-SHA512: 98d529d3bb0dbbf4bbafeea7d30ec5e5816ac9800ba2cb7981fc6189b4b02774956c3ddbb74bf0b3e6e22798bfced36508263e4e89c248b7a6240c5c7109107b
2 parents f6c1c61 + 90fd1a2 commit 2a1787b

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

crates/esplora/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ workspace = true
1616

1717
[dependencies]
1818
bdk_core = { path = "../core", version = "0.3.0", default-features = false }
19-
esplora-client = { version = "0.10.0", default-features = false }
19+
esplora-client = { version = "0.11.0", default-features = false }
2020
async-trait = { version = "0.1.66", optional = true }
2121
futures = { version = "0.3.26", optional = true }
2222
miniscript = { version = "12.0.0", optional = true, default-features = false }
2323

2424
[dev-dependencies]
25+
esplora-client = { version = "0.11.0" }
2526
bdk_chain = { path = "../chain" }
2627
bdk_testenv = { path = "../testenv" }
2728
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
2829

2930
[features]
3031
default = ["std", "async-https", "blocking-https"]
3132
std = ["bdk_chain/std", "miniscript?/std"]
33+
tokio = ["esplora-client/tokio"]
3234
async = ["async-trait", "futures", "esplora-client/async"]
3335
async-https = ["async", "esplora-client/async-https"]
3436
async-https-rustls = ["async", "esplora-client/async-https-rustls"]

crates/esplora/README.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@ The extension traits are primarily intended to satisfy [`SyncRequest`]s with [`s
1010

1111
For blocking-only:
1212
```toml
13-
bdk_esplora = { version = "0.3", features = ["blocking"] }
13+
bdk_esplora = { version = "0.19", features = ["blocking"] }
1414
```
1515

1616
For async-only:
1717
```toml
18-
bdk_esplora = { version = "0.3", features = ["async"] }
18+
bdk_esplora = { version = "0.19", features = ["async"] }
1919
```
2020

2121
For async-only (with https):
22+
23+
You can additionally specify to use either rustls or native-tls, e.g. `async-https-native`, and this applies to both async and blocking features.
24+
```toml
25+
bdk_esplora = { version = "0.19", features = ["async-https"] }
26+
```
27+
28+
For async-only (with tokio):
2229
```toml
23-
bdk_esplora = { version = "0.3", features = ["async-https"] }
30+
bdk_esplora = { version = "0.19", features = ["async", "tokio"] }
2431
```
2532

2633
To use the extension traits:
@@ -34,7 +41,7 @@ use bdk_esplora::EsploraExt;
3441
use bdk_esplora::EsploraAsyncExt;
3542
```
3643

37-
For full examples, refer to [`example-crates/wallet_esplora_blocking`](https://github.com/bitcoindevkit/bdk/tree/master/example-crates/wallet_esplora_blocking) and [`example-crates/wallet_esplora_async`](https://github.com/bitcoindevkit/bdk/tree/master/example-crates/wallet_esplora_async).
44+
For full examples, refer to [`example_wallet_esplora_blocking`](https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_wallet_esplora_blocking) and [`example_wallet_esplora_async`](https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_wallet_esplora_async).
3845

3946
[`esplora-client`]: https://docs.rs/esplora-client/
4047
[`bdk_chain`]: https://docs.rs/bdk-chain/

crates/esplora/src/async_ext.rs

+31-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use bdk_core::{
55
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
66
BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate,
77
};
8+
use esplora_client::Sleeper;
89
use futures::{stream::FuturesOrdered, TryStreamExt};
910

1011
use crate::{insert_anchor_from_status, insert_prevouts};
@@ -50,7 +51,11 @@ pub trait EsploraAsyncExt {
5051

5152
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
5253
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
53-
impl EsploraAsyncExt for esplora_client::AsyncClient {
54+
impl<S> EsploraAsyncExt for esplora_client::AsyncClient<S>
55+
where
56+
S: Sleeper + Clone + Send + Sync,
57+
S::Sleep: Send,
58+
{
5459
async fn full_scan<K: Ord + Clone + Send, R: Into<FullScanRequest<K>> + Send>(
5560
&self,
5661
request: R,
@@ -165,8 +170,8 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
165170
/// block-based chain-sources). Therefore it's better to be conservative when setting the tip (use
166171
/// an earlier tip rather than a later tip) otherwise the caller may accidentally skip blocks when
167172
/// alternating between chain-sources.
168-
async fn fetch_latest_blocks(
169-
client: &esplora_client::AsyncClient,
173+
async fn fetch_latest_blocks<S: Sleeper>(
174+
client: &esplora_client::AsyncClient<S>,
170175
) -> Result<BTreeMap<u32, BlockHash>, Error> {
171176
Ok(client
172177
.get_blocks(None)
@@ -179,8 +184,8 @@ async fn fetch_latest_blocks(
179184
/// Used instead of [`esplora_client::BlockingClient::get_block_hash`].
180185
///
181186
/// This first checks the previously fetched `latest_blocks` before fetching from Esplora again.
182-
async fn fetch_block(
183-
client: &esplora_client::AsyncClient,
187+
async fn fetch_block<S: Sleeper>(
188+
client: &esplora_client::AsyncClient<S>,
184189
latest_blocks: &BTreeMap<u32, BlockHash>,
185190
height: u32,
186191
) -> Result<Option<BlockHash>, Error> {
@@ -205,8 +210,8 @@ async fn fetch_block(
205210
///
206211
/// We want to have a corresponding checkpoint per anchor height. However, checkpoints fetched
207212
/// should not surpass `latest_blocks`.
208-
async fn chain_update(
209-
client: &esplora_client::AsyncClient,
213+
async fn chain_update<S: Sleeper>(
214+
client: &esplora_client::AsyncClient<S>,
210215
latest_blocks: &BTreeMap<u32, BlockHash>,
211216
local_tip: &CheckPoint,
212217
anchors: &BTreeSet<(ConfirmationBlockTime, Txid)>,
@@ -271,13 +276,17 @@ async fn chain_update(
271276
/// script pubkey that contains a non-empty transaction history.
272277
///
273278
/// Refer to [crate-level docs](crate) for more.
274-
async fn fetch_txs_with_keychain_spks<I: Iterator<Item = Indexed<ScriptBuf>> + Send>(
275-
client: &esplora_client::AsyncClient,
279+
async fn fetch_txs_with_keychain_spks<I, S>(
280+
client: &esplora_client::AsyncClient<S>,
276281
inserted_txs: &mut HashSet<Txid>,
277282
mut keychain_spks: I,
278283
stop_gap: usize,
279284
parallel_requests: usize,
280-
) -> Result<(TxUpdate<ConfirmationBlockTime>, Option<u32>), Error> {
285+
) -> Result<(TxUpdate<ConfirmationBlockTime>, Option<u32>), Error>
286+
where
287+
I: Iterator<Item = Indexed<ScriptBuf>> + Send,
288+
S: Sleeper + Clone + Send + Sync,
289+
{
281290
type TxsOfSpkIndex = (u32, Vec<esplora_client::Tx>);
282291

283292
let mut update = TxUpdate::<ConfirmationBlockTime>::default();
@@ -346,14 +355,16 @@ async fn fetch_txs_with_keychain_spks<I: Iterator<Item = Indexed<ScriptBuf>> + S
346355
/// HTTP requests to make in parallel.
347356
///
348357
/// Refer to [crate-level docs](crate) for more.
349-
async fn fetch_txs_with_spks<I: IntoIterator<Item = ScriptBuf> + Send>(
350-
client: &esplora_client::AsyncClient,
358+
async fn fetch_txs_with_spks<I, S>(
359+
client: &esplora_client::AsyncClient<S>,
351360
inserted_txs: &mut HashSet<Txid>,
352361
spks: I,
353362
parallel_requests: usize,
354363
) -> Result<TxUpdate<ConfirmationBlockTime>, Error>
355364
where
365+
I: IntoIterator<Item = ScriptBuf> + Send,
356366
I::IntoIter: Send,
367+
S: Sleeper + Clone + Send + Sync,
357368
{
358369
fetch_txs_with_keychain_spks(
359370
client,
@@ -372,14 +383,16 @@ where
372383
/// `parallel_requests` specifies the maximum number of HTTP requests to make in parallel.
373384
///
374385
/// Refer to [crate-level docs](crate) for more.
375-
async fn fetch_txs_with_txids<I: IntoIterator<Item = Txid> + Send>(
376-
client: &esplora_client::AsyncClient,
386+
async fn fetch_txs_with_txids<I, S>(
387+
client: &esplora_client::AsyncClient<S>,
377388
inserted_txs: &mut HashSet<Txid>,
378389
txids: I,
379390
parallel_requests: usize,
380391
) -> Result<TxUpdate<ConfirmationBlockTime>, Error>
381392
where
393+
I: IntoIterator<Item = Txid> + Send,
382394
I::IntoIter: Send,
395+
S: Sleeper + Clone + Send + Sync,
383396
{
384397
let mut update = TxUpdate::<ConfirmationBlockTime>::default();
385398
// Only fetch for non-inserted txs.
@@ -421,14 +434,16 @@ where
421434
/// `parallel_requests` specifies the maximum number of HTTP requests to make in parallel.
422435
///
423436
/// Refer to [crate-level docs](crate) for more.
424-
async fn fetch_txs_with_outpoints<I: IntoIterator<Item = OutPoint> + Send>(
425-
client: &esplora_client::AsyncClient,
437+
async fn fetch_txs_with_outpoints<I, S>(
438+
client: &esplora_client::AsyncClient<S>,
426439
inserted_txs: &mut HashSet<Txid>,
427440
outpoints: I,
428441
parallel_requests: usize,
429442
) -> Result<TxUpdate<ConfirmationBlockTime>, Error>
430443
where
444+
I: IntoIterator<Item = OutPoint> + Send,
431445
I::IntoIter: Send,
446+
S: Sleeper + Clone + Send + Sync,
432447
{
433448
let outpoints = outpoints.into_iter().collect::<Vec<_>>();
434449
let mut update = TxUpdate::<ConfirmationBlockTime>::default();

example-crates/example_wallet_esplora_async/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ edition = "2021"
77

88
[dependencies]
99
bdk_wallet = { path = "../../crates/wallet", features = ["rusqlite"] }
10-
bdk_esplora = { path = "../../crates/esplora", features = ["async-https"] }
10+
bdk_esplora = { path = "../../crates/esplora", features = ["async-https", "tokio"] }
1111
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
1212
anyhow = "1"

0 commit comments

Comments
 (0)