41
41
//! specific features, set `default-features` to `false` in your `Cargo.toml`
42
42
//! and specify the features you want. This will look like this:
43
43
//!
44
- //! `esplora-client = { version = "*", default-features = false, features = ["blocking"] }`
44
+ //! `esplora-client = { version = "*", default-features = false, features =
45
+ //! ["blocking"] }`
45
46
//!
46
47
//! * `blocking` enables [`minreq`], the blocking client with proxy.
47
- //! * `blocking-https` enables [`minreq`], the blocking client with proxy and TLS (SSL)
48
- //! capabilities using the default [`minreq`] backend.
49
- //! * `blocking-https-rustls` enables [`minreq`], the blocking client with proxy and TLS (SSL)
50
- //! capabilities using the `rustls` backend.
51
- //! * `blocking-https-native` enables [`minreq`], the blocking client with proxy and TLS (SSL)
52
- //! capabilities using the platform's native TLS backend (likely OpenSSL).
53
- //! * `blocking-https-bundled` enables [`minreq`], the blocking client with proxy and TLS (SSL)
54
- //! capabilities using a bundled OpenSSL library backend.
55
- //! * `async` enables [`reqwest`], the async client with proxy capabilities.
56
- //! * `async-https` enables [`reqwest`], the async client with support for proxying and TLS (SSL)
57
- //! using the default [`reqwest`] TLS backend.
58
- //! * `async-https-native` enables [`reqwest`], the async client with support for proxying and TLS
59
- //! (SSL) using the platform's native TLS backend (likely OpenSSL).
60
- //! * `async-https-rustls` enables [`reqwest`], the async client with support for proxying and TLS
61
- //! (SSL) using the `rustls` TLS backend.
62
- //! * `async-https-rustls-manual-roots` enables [`reqwest`], the async client with support for
63
- //! proxying and TLS (SSL) using the `rustls` TLS backend without using its the default root
64
- //! certificates.
48
+ //! * `blocking-https` enables [`minreq`], the blocking client with proxy and
49
+ //! TLS (SSL) capabilities using the default [`minreq`] backend.
50
+ //! * `blocking-https-rustls` enables [`minreq`], the blocking client with proxy
51
+ //! and TLS (SSL) capabilities using the `rustls` backend.
52
+ //! * `blocking-https-native` enables [`minreq`], the blocking client with proxy
53
+ //! and TLS (SSL) capabilities using the platform's native TLS backend (likely
54
+ //! OpenSSL).
55
+ //! * `blocking-https-bundled` enables [`minreq`], the blocking client with
56
+ //! proxy and TLS (SSL) capabilities using a bundled OpenSSL library backend.
65
57
//!
58
+ //! * `async` enables [`reqwest`], the async client with proxy capabilities.
59
+ //! * `async-https` enables [`reqwest`], the async client with support for
60
+ //! proxying and TLS (SSL) using the default [`reqwest`] TLS backend.
61
+ //! * `async-https-native` enables [`reqwest`], the async client with support
62
+ //! for proxying and TLS (SSL) using the platform's native TLS backend (likely
63
+ //! OpenSSL).
64
+ //! * `async-https-rustls` enables [`reqwest`], the async client with support
65
+ //! for proxying and TLS (SSL) using the `rustls` TLS backend.
66
+ //! * `async-https-rustls-manual-roots` enables [`reqwest`], the async client
67
+ //! with support for proxying and TLS (SSL) using the `rustls` TLS backend
68
+ //! without using its the default root certificates.
66
69
//!
67
70
68
71
#![ allow( clippy:: result_large_err) ]
@@ -71,8 +74,6 @@ use std::collections::HashMap;
71
74
use std:: fmt;
72
75
use std:: num:: TryFromIntError ;
73
76
74
- use bitcoin:: consensus;
75
-
76
77
pub mod api;
77
78
78
79
#[ cfg( feature = "async" ) ]
@@ -103,21 +104,24 @@ pub fn convert_fee_rate(target: usize, estimates: HashMap<u16, f64>) -> Result<f
103
104
104
105
#[ derive( Debug , Clone ) ]
105
106
pub struct Builder {
107
+ /// The URL of the Esplora server.
106
108
pub base_url : String ,
107
109
/// Optional URL of the proxy to use to make requests to the Esplora server
108
110
///
109
- /// The string should be formatted as: `<protocol>://<user>:<password>@host:<port>`.
111
+ /// The string should be formatted as:
112
+ /// `<protocol>://<user>:<password>@host:<port>`.
110
113
///
111
- /// Note that the format of this value and the supported protocols change slightly between the
112
- /// blocking version of the client (using `minreq`) and the async version (using `reqwest`). For more
113
- /// details check with the documentation of the two crates. Both of them are compiled with
114
+ /// Note that the format of this value and the supported protocols change
115
+ /// slightly between the blocking version of the client (using `minreq`)
116
+ /// and the async version (using `reqwest`). For more details check with
117
+ /// the documentation of the two crates. Both of them are compiled with
114
118
/// the `socks` feature enabled.
115
119
///
116
120
/// The proxy is ignored when targeting `wasm32`.
117
121
pub proxy : Option < String > ,
118
122
/// Socket timeout.
119
123
pub timeout : Option < u64 > ,
120
- /// HTTP headers to set on every request made to Esplora server
124
+ /// HTTP headers to set on every request made to Esplora server.
121
125
pub headers : HashMap < String , String > ,
122
126
}
123
127
@@ -150,20 +154,20 @@ impl Builder {
150
154
self
151
155
}
152
156
153
- /// build a blocking client from builder
157
+ /// Build a blocking client from builder
154
158
#[ cfg( feature = "blocking" ) ]
155
159
pub fn build_blocking ( self ) -> BlockingClient {
156
160
BlockingClient :: from_builder ( self )
157
161
}
158
162
159
- // build an asynchronous client from builder
163
+ // Build an asynchronous client from builder
160
164
#[ cfg( feature = "async" ) ]
161
165
pub fn build_async ( self ) -> Result < AsyncClient , Error > {
162
166
AsyncClient :: from_builder ( self )
163
167
}
164
168
}
165
169
166
- /// Errors that can happen during a sync with `Esplora`
170
+ /// Errors that can happen during a request to `Esplora` servers.
167
171
#[ derive( Debug ) ]
168
172
pub enum Error {
169
173
/// Error during `minreq` HTTP request
@@ -186,9 +190,9 @@ pub enum Error {
186
190
HexToBytes ( bitcoin:: hex:: HexToBytesError ) ,
187
191
/// Transaction not found
188
192
TransactionNotFound ( Txid ) ,
189
- /// Header height not found
193
+ /// Block Header height not found
190
194
HeaderHeightNotFound ( u32 ) ,
191
- /// Header hash not found
195
+ /// Block Header hash not found
192
196
HeaderHashNotFound ( BlockHash ) ,
193
197
/// Invalid HTTP Header name specified
194
198
InvalidHttpHeaderName ( String ) ,
@@ -221,7 +225,7 @@ impl_error!(::minreq::Error, Minreq, Error);
221
225
#[ cfg( feature = "async" ) ]
222
226
impl_error ! ( :: reqwest:: Error , Reqwest , Error ) ;
223
227
impl_error ! ( std:: num:: ParseIntError , Parsing , Error ) ;
224
- impl_error ! ( consensus:: encode:: Error , BitcoinEncoding , Error ) ;
228
+ impl_error ! ( bitcoin :: consensus:: encode:: Error , BitcoinEncoding , Error ) ;
225
229
impl_error ! ( bitcoin:: hex:: HexToArrayError , HexToArray , Error ) ;
226
230
impl_error ! ( bitcoin:: hex:: HexToBytesError , HexToBytes , Error ) ;
227
231
@@ -592,8 +596,8 @@ mod test {
592
596
#[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
593
597
#[ tokio:: test]
594
598
async fn test_get_non_existing_block_status ( ) {
595
- // Esplora returns the same status for orphaned blocks as for non-existing blocks:
596
- // non-existing: https://blockstream.info/api/block/0000000000000000000000000000000000000000000000000000000000000000/status
599
+ // Esplora returns the same status for orphaned blocks as for non-existing
600
+ // blocks: non-existing: https://blockstream.info/api/block/0000000000000000000000000000000000000000000000000000000000000000/status
597
601
// orphaned: https://blockstream.info/api/block/000000000000000000181b1a2354620f66868a723c0c4d5b24e4be8bdfc35a7f/status
598
602
// (Here the block is cited as orphaned: https://bitcoinchain.com/block_explorer/block/000000000000000000181b1a2354620f66868a723c0c4d5b24e4be8bdfc35a7f/ )
599
603
// For this reason, we only test for the non-existing case here.
0 commit comments