14
14
//! You can create a blocking client as follows:
15
15
//!
16
16
//! ```no_run
17
+ //! # #[cfg(feature = "blocking")]
18
+ //! # {
17
19
//! use esplora_client::Builder;
18
20
//! let builder = Builder::new("https://blockstream.info/testnet/api");
19
21
//! let blocking_client = builder.build_blocking();
20
22
//! # Ok::<(), esplora_client::Error>(());
23
+ //! # }
21
24
//! ```
22
25
//!
23
26
//! Here is an example of how to create an asynchronous client.
24
27
//!
25
28
//! ```no_run
29
+ //! # #[cfg(feature = "async")]
30
+ //! # {
26
31
//! use esplora_client::Builder;
27
32
//! let builder = Builder::new("https://blockstream.info/testnet/api");
28
33
//! let async_client = builder.build_async();
29
34
//! # Ok::<(), esplora_client::Error>(());
35
+ //! # }
30
36
//! ```
31
37
//!
32
38
//! ## Features
@@ -54,15 +60,15 @@ use bitcoin::{BlockHash, Txid};
54
60
55
61
pub mod api;
56
62
57
- #[ cfg( any ( feature = "async" , feature = "async-https" ) ) ]
63
+ #[ cfg( feature = "async" ) ]
58
64
pub mod r#async;
59
65
#[ cfg( feature = "blocking" ) ]
60
66
pub mod blocking;
61
67
62
68
pub use api:: * ;
63
69
#[ cfg( feature = "blocking" ) ]
64
70
pub use blocking:: BlockingClient ;
65
- #[ cfg( any ( feature = "async" , feature = "async-https" ) ) ]
71
+ #[ cfg( feature = "async" ) ]
66
72
pub use r#async:: AsyncClient ;
67
73
68
74
/// Get a fee value in sats/vbytes from the estimates
@@ -146,7 +152,7 @@ pub enum Error {
146
152
#[ cfg( feature = "blocking" ) ]
147
153
UreqTransport ( :: ureq:: Transport ) ,
148
154
/// Error during reqwest HTTP request
149
- #[ cfg( any ( feature = "async" , feature = "async-https" ) ) ]
155
+ #[ cfg( feature = "async" ) ]
150
156
Reqwest ( :: reqwest:: Error ) ,
151
157
/// HTTP response error
152
158
HttpResponse ( u16 ) ,
@@ -191,7 +197,7 @@ macro_rules! impl_error {
191
197
impl std:: error:: Error for Error { }
192
198
#[ cfg( feature = "blocking" ) ]
193
199
impl_error ! ( :: ureq:: Transport , UreqTransport , Error ) ;
194
- #[ cfg( any ( feature = "async" , feature = "async-https" ) ) ]
200
+ #[ cfg( feature = "async" ) ]
195
201
impl_error ! ( :: reqwest:: Error , Reqwest , Error ) ;
196
202
impl_error ! ( io:: Error , Io , Error ) ;
197
203
impl_error ! ( std:: num:: ParseIntError , Parsing , Error ) ;
@@ -205,7 +211,7 @@ mod test {
205
211
use lazy_static:: lazy_static;
206
212
use std:: env;
207
213
use tokio:: sync:: Mutex ;
208
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
214
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
209
215
use {
210
216
bitcoin:: hashes:: Hash ,
211
217
bitcoin:: Amount ,
@@ -243,10 +249,10 @@ mod test {
243
249
static ref MINER : Mutex <( ) > = Mutex :: new( ( ) ) ;
244
250
}
245
251
246
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
252
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
247
253
static PREMINE : OnceCell < ( ) > = OnceCell :: const_new ( ) ;
248
254
249
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
255
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
250
256
async fn setup_clients ( ) -> ( BlockingClient , AsyncClient ) {
251
257
PREMINE
252
258
. get_or_init ( || async {
@@ -266,14 +272,14 @@ mod test {
266
272
( blocking_client, async_client)
267
273
}
268
274
269
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
275
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
270
276
fn generate_blocks_and_wait ( num : usize ) {
271
277
let cur_height = BITCOIND . client . get_block_count ( ) . unwrap ( ) ;
272
278
generate_blocks ( num) ;
273
279
wait_for_block ( cur_height as usize + num) ;
274
280
}
275
281
276
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
282
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
277
283
fn generate_blocks ( num : usize ) {
278
284
let address = BITCOIND
279
285
. client
@@ -285,7 +291,7 @@ mod test {
285
291
. unwrap ( ) ;
286
292
}
287
293
288
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
294
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
289
295
fn wait_for_block ( min_height : usize ) {
290
296
let mut header = ELECTRSD . client . block_headers_subscribe ( ) . unwrap ( ) ;
291
297
loop {
@@ -300,7 +306,7 @@ mod test {
300
306
}
301
307
}
302
308
303
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
309
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
304
310
fn exponential_backoff_poll < T , F > ( mut poll : F ) -> T
305
311
where
306
312
F : FnMut ( ) -> Option < T > ,
@@ -361,7 +367,7 @@ mod test {
361
367
) ;
362
368
}
363
369
364
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
370
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
365
371
#[ tokio:: test]
366
372
async fn test_get_tx ( ) {
367
373
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -391,7 +397,7 @@ mod test {
391
397
assert_eq ! ( tx, tx_async) ;
392
398
}
393
399
394
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
400
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
395
401
#[ tokio:: test]
396
402
async fn test_get_tx_no_opt ( ) {
397
403
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -421,7 +427,7 @@ mod test {
421
427
assert_eq ! ( tx_no_opt, tx_no_opt_async) ;
422
428
}
423
429
424
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
430
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
425
431
#[ tokio:: test]
426
432
async fn test_get_tx_status ( ) {
427
433
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -452,7 +458,7 @@ mod test {
452
458
assert ! ( tx_status. confirmed) ;
453
459
}
454
460
455
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
461
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
456
462
#[ tokio:: test]
457
463
async fn test_get_header_by_hash ( ) {
458
464
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -464,7 +470,7 @@ mod test {
464
470
assert_eq ! ( block_header, block_header_async) ;
465
471
}
466
472
467
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
473
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
468
474
#[ tokio:: test]
469
475
async fn test_get_block_status ( ) {
470
476
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -484,7 +490,7 @@ mod test {
484
490
assert_eq ! ( expected, block_status_async) ;
485
491
}
486
492
487
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
493
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
488
494
#[ tokio:: test]
489
495
async fn test_get_non_existing_block_status ( ) {
490
496
// Esplora returns the same status for orphaned blocks as for non-existing blocks:
@@ -509,7 +515,7 @@ mod test {
509
515
assert_eq ! ( expected, block_status_async) ;
510
516
}
511
517
512
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
518
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
513
519
#[ tokio:: test]
514
520
async fn test_get_block_by_hash ( ) {
515
521
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -524,7 +530,7 @@ mod test {
524
530
assert_eq ! ( expected, block_async) ;
525
531
}
526
532
527
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
533
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
528
534
#[ tokio:: test]
529
535
async fn test_get_block_by_hash_not_existing ( ) {
530
536
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -540,7 +546,7 @@ mod test {
540
546
assert ! ( block_async. is_none( ) ) ;
541
547
}
542
548
543
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
549
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
544
550
#[ tokio:: test]
545
551
async fn test_get_merkle_proof ( ) {
546
552
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -571,7 +577,7 @@ mod test {
571
577
assert ! ( merkle_proof. pos > 0 ) ;
572
578
}
573
579
574
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
580
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
575
581
#[ tokio:: test]
576
582
async fn test_get_merkle_block ( ) {
577
583
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -611,7 +617,7 @@ mod test {
611
617
assert ! ( indexes[ 0 ] > 0 ) ;
612
618
}
613
619
614
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
620
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
615
621
#[ tokio:: test]
616
622
async fn test_get_output_status ( ) {
617
623
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -649,7 +655,7 @@ mod test {
649
655
assert_eq ! ( output_status, output_status_async) ;
650
656
}
651
657
652
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
658
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
653
659
#[ tokio:: test]
654
660
async fn test_get_height ( ) {
655
661
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -659,7 +665,7 @@ mod test {
659
665
assert_eq ! ( block_height, block_height_async) ;
660
666
}
661
667
662
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
668
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
663
669
#[ tokio:: test]
664
670
async fn test_get_tip_hash ( ) {
665
671
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -668,7 +674,7 @@ mod test {
668
674
assert_eq ! ( tip_hash, tip_hash_async) ;
669
675
}
670
676
671
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
677
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
672
678
#[ tokio:: test]
673
679
async fn test_get_block_hash ( ) {
674
680
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -681,7 +687,7 @@ mod test {
681
687
assert_eq ! ( block_hash, block_hash_async) ;
682
688
}
683
689
684
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
690
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
685
691
#[ tokio:: test]
686
692
async fn test_get_txid_at_block_index ( ) {
687
693
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -700,7 +706,7 @@ mod test {
700
706
assert_eq ! ( txid_at_block_index, txid_at_block_index_async) ;
701
707
}
702
708
703
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
709
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
704
710
#[ tokio:: test]
705
711
async fn test_get_fee_estimates ( ) {
706
712
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -709,7 +715,7 @@ mod test {
709
715
assert_eq ! ( fee_estimates. len( ) , fee_estimates_async. len( ) ) ;
710
716
}
711
717
712
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
718
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
713
719
#[ tokio:: test]
714
720
async fn test_scripthash_txs ( ) {
715
721
let ( blocking_client, async_client) = setup_clients ( ) . await ;
@@ -757,7 +763,7 @@ mod test {
757
763
assert_eq ! ( scripthash_txs_txids, scripthash_txs_txids_async) ;
758
764
}
759
765
760
- #[ cfg( all( feature = "blocking" , any ( feature = "async" , feature = "async-https" ) ) ) ]
766
+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
761
767
#[ tokio:: test]
762
768
async fn test_get_blocks ( ) {
763
769
let ( blocking_client, async_client) = setup_clients ( ) . await ;
0 commit comments