|
1 | 1 | //! Esplora
|
2 | 2 | //!
|
3 |
| -//! This module defines a [`Builder`] struct that can create a blocking or |
| 3 | +//! This module defines a [`Builder`] struct that can create a blocking or |
4 | 4 | //! async Esplora client to query an Esplora backend:
|
5 | 5 | //!
|
6 | 6 | //! ## Examples
|
@@ -32,13 +32,16 @@ use bitcoin::consensus;
|
32 | 32 | use bitcoin::{BlockHash, Txid};
|
33 | 33 |
|
34 | 34 | pub mod api;
|
35 |
| -#[cfg(feature = "async")] |
| 35 | + |
| 36 | +#[cfg(any(feature = "async", feature = "async-https"))] |
36 | 37 | pub mod r#async;
|
37 | 38 | #[cfg(feature = "blocking")]
|
38 | 39 | pub mod blocking;
|
39 | 40 |
|
40 | 41 | pub use api::*;
|
| 42 | +#[cfg(feature = "blocking")] |
41 | 43 | pub use blocking::BlockingClient;
|
| 44 | +#[cfg(any(feature = "async", feature = "async-https"))] |
42 | 45 | pub use r#async::AsyncClient;
|
43 | 46 |
|
44 | 47 | pub fn convert_fee_rate(target: usize, estimates: HashMap<String, f64>) -> Result<f32, Error> {
|
@@ -109,13 +112,13 @@ impl Builder {
|
109 | 112 | #[derive(Debug)]
|
110 | 113 | pub enum Error {
|
111 | 114 | /// Error during ureq HTTP request
|
112 |
| - #[cfg(feature = "ureq")] |
| 115 | + #[cfg(feature = "blocking")] |
113 | 116 | Ureq(::ureq::Error),
|
114 | 117 | /// Transport error during the ureq HTTP call
|
115 |
| - #[cfg(feature = "ureq")] |
| 118 | + #[cfg(feature = "blocking")] |
116 | 119 | UreqTransport(::ureq::Transport),
|
117 | 120 | /// Error during reqwest HTTP request
|
118 |
| - #[cfg(feature = "reqwest")] |
| 121 | + #[cfg(any(feature = "async", feature = "async-https"))] |
119 | 122 | Reqwest(::reqwest::Error),
|
120 | 123 | /// HTTP response error
|
121 | 124 | HttpResponse(u16),
|
@@ -158,8 +161,9 @@ macro_rules! impl_error {
|
158 | 161 | }
|
159 | 162 |
|
160 | 163 | impl std::error::Error for Error {}
|
161 |
| - |
| 164 | +#[cfg(feature = "blocking")] |
162 | 165 | impl_error!(::ureq::Transport, UreqTransport, Error);
|
| 166 | +#[cfg(any(feature = "async", feature = "async-https"))] |
163 | 167 | impl_error!(::reqwest::Error, Reqwest, Error);
|
164 | 168 | impl_error!(io::Error, Io, Error);
|
165 | 169 | impl_error!(std::num::ParseIntError, Parsing, Error);
|
@@ -206,10 +210,7 @@ mod test {
|
206 | 210 | "#,
|
207 | 211 | )
|
208 | 212 | .unwrap();
|
209 |
| - assert_eq!( |
210 |
| - convert_fee_rate(6, esplora_fees.clone()).unwrap(), |
211 |
| - 2.236 |
212 |
| - ); |
| 213 | + assert_eq!(convert_fee_rate(6, esplora_fees.clone()).unwrap(), 2.236); |
213 | 214 | assert_eq!(
|
214 | 215 | convert_fee_rate(26, esplora_fees).unwrap(),
|
215 | 216 | 1.015,
|
|
0 commit comments