Skip to content

Commit ee96f7a

Browse files
committed
fix: formatting issue fixed.
1 parent 60dcc98 commit ee96f7a

File tree

2 files changed

+52
-52
lines changed

2 files changed

+52
-52
lines changed

src/async.rs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,25 @@
1111

1212
//! Esplora by way of `reqwest` HTTP client.
1313
14-
use std::collections::HashMap;
15-
use std::marker::PhantomData;
16-
use std::str::FromStr;
1714
use bitcoin::consensus::{deserialize, serialize, Decodable, Encodable};
1815
use bitcoin::hashes::{sha256, Hash};
1916
use bitcoin::hex::{DisplayHex, FromHex};
2017
use bitcoin::Address;
2118
use bitcoin::{
2219
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
2320
};
21+
use std::collections::HashMap;
22+
use std::marker::PhantomData;
23+
use std::str::FromStr;
2424

25-
#[allow(unused_imports)]
26-
use log::{debug, error, info, trace};
27-
28-
use async_minreq::{Method, Request};
2925
use crate::api::AddressStats;
3026
use crate::{
3127
BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus,
3228
BASE_BACKOFF_MILLIS, RETRYABLE_ERROR_CODES,
3329
};
30+
use async_minreq::{Method, Request};
31+
#[allow(unused_imports)]
32+
use log::{debug, error, info, trace};
3433

3534
#[derive(Debug, Clone)]
3635
pub struct AsyncClient<S = DefaultSleeper> {
@@ -47,15 +46,15 @@ pub struct AsyncClient<S = DefaultSleeper> {
4746
impl<S: Sleeper> AsyncClient<S> {
4847
/// Build an async client from a builder
4948
pub fn from_builder(builder: Builder) -> Result<Self, Error> {
50-
Ok(AsyncClient {
49+
Ok(AsyncClient {
5150
url: builder.base_url,
5251
max_retries: builder.max_retries,
5352
headers: builder.headers,
5453
marker: PhantomData,
5554
})
5655
}
5756

58-
pub fn from_client(url: String, headers: HashMap<String, String>,) -> Self {
57+
pub fn from_client(url: String, headers: HashMap<String, String>) -> Self {
5958
AsyncClient {
6059
url,
6160
headers,
@@ -78,17 +77,17 @@ impl<S: Sleeper> AsyncClient<S> {
7877
let url = format!("{}{}", self.url, path);
7978
let response = self.get_with_retry(&url).await?;
8079

81-
if response.status_code>299 {
80+
if response.status_code > 299 {
8281
return Err(Error::HttpResponse {
8382
status: response.status_code as u16,
84-
message:match response.as_str(){
85-
Ok(resp)=> resp.to_string(),
86-
Err(_) => return Err(Error::InvalidResponse),
87-
}
83+
message: match response.as_str() {
84+
Ok(resp) => resp.to_string(),
85+
Err(_) => return Err(Error::InvalidResponse),
86+
},
8887
});
8988
}
9089

91-
Ok(deserialize::<T>(&response.as_bytes())?)
90+
Ok(deserialize::<T>(response.as_bytes())?)
9291
}
9392

9493
/// Make an HTTP GET request to given URL, deserializing to `Option<T>`.
@@ -121,19 +120,20 @@ impl<S: Sleeper> AsyncClient<S> {
121120
let url = format!("{}{}", self.url, path);
122121
let response = self.get_with_retry(&url).await?;
123122

124-
if response.status_code>299 {
123+
if response.status_code > 299 {
125124
return Err(Error::HttpResponse {
126125
status: response.status_code as u16,
127-
message: match response.as_str(){
128-
Ok(resp)=> resp.to_string(),
129-
Err(_) => return Err(Error::InvalidResponse),
130-
},
126+
message: match response.as_str() {
127+
Ok(resp) => resp.to_string(),
128+
Err(_) => return Err(Error::InvalidResponse),
129+
},
131130
});
132131
}
133-
serde_json::from_str(match response.as_str(){
134-
Ok(resp)=> resp,
135-
Err(_) => return Err(Error::InvalidResponse),
136-
}).map_err(Error::Json)
132+
serde_json::from_str(match response.as_str() {
133+
Ok(resp) => resp,
134+
Err(_) => return Err(Error::InvalidResponse),
135+
})
136+
.map_err(Error::Json)
137137
}
138138

139139
/// Make an HTTP GET request to given URL, deserializing to `Option<T>`.
@@ -168,19 +168,19 @@ impl<S: Sleeper> AsyncClient<S> {
168168
let url = format!("{}{}", self.url, path);
169169
let response = self.get_with_retry(&url).await?;
170170

171-
if response.status_code>299 {
171+
if response.status_code > 299 {
172172
return Err(Error::HttpResponse {
173173
status: response.status_code as u16,
174-
message:match response.as_str(){
175-
Ok(resp)=> resp.to_string(),
176-
Err(_) => return Err(Error::InvalidResponse),
177-
}
174+
message: match response.as_str() {
175+
Ok(resp) => resp.to_string(),
176+
Err(_) => return Err(Error::InvalidResponse),
177+
},
178178
});
179179
}
180-
let hex_str =match response.as_str(){
181-
Ok(resp)=> resp.to_string(),
182-
Err(_) => return Err(Error::InvalidResponse),
183-
};
180+
let hex_str = match response.as_str() {
181+
Ok(resp) => resp.to_string(),
182+
Err(_) => return Err(Error::InvalidResponse),
183+
};
184184
Ok(deserialize(&Vec::from_hex(&hex_str)?)?)
185185
}
186186

@@ -210,19 +210,19 @@ impl<S: Sleeper> AsyncClient<S> {
210210
let url = format!("{}{}", self.url, path);
211211
let response = self.get_with_retry(&url).await?;
212212

213-
if response.status_code>299 {
213+
if response.status_code > 299 {
214214
return Err(Error::HttpResponse {
215215
status: response.status_code as u16,
216-
message:match response.as_str(){
217-
Ok(resp)=> resp.to_string(),
218-
Err(_) => return Err(Error::InvalidResponse),
219-
}
216+
message: match response.as_str() {
217+
Ok(resp) => resp.to_string(),
218+
Err(_) => return Err(Error::InvalidResponse),
219+
},
220220
});
221221
}
222-
Ok(match response.as_str(){
223-
Ok(resp)=> resp.to_string(),
224-
Err(_) => return Err(Error::InvalidResponse),
225-
})
222+
Ok(match response.as_str() {
223+
Ok(resp) => resp.to_string(),
224+
Err(_) => return Err(Error::InvalidResponse),
225+
})
226226
}
227227

228228
/// Make an HTTP GET request to given URL, deserializing to `Option<T>`.
@@ -257,15 +257,15 @@ impl<S: Sleeper> AsyncClient<S> {
257257
for (key, value) in &self.headers {
258258
request = request.with_header(key, value);
259259
}
260-
260+
261261
let response = request.send().await.map_err(Error::AsyncMinreq)?;
262-
if response.status_code>299{
262+
if response.status_code > 299 {
263263
return Err(Error::HttpResponse {
264264
status: response.status_code as u16,
265-
message: match response.as_str(){
266-
Ok(resp)=> resp.to_string(),
267-
Err(_) => return Err(Error::InvalidResponse),
268-
}
265+
message: match response.as_str() {
266+
Ok(resp) => resp.to_string(),
267+
Err(_) => return Err(Error::InvalidResponse),
268+
},
269269
});
270270
}
271271
Ok(())
@@ -457,7 +457,7 @@ impl<S: Sleeper> AsyncClient<S> {
457457
let mut attempts = 0;
458458

459459
loop {
460-
let mut request = Request::new(Method::Get, url);
460+
let mut request = Request::new(Method::Get, url);
461461
for (key, value) in &self.headers {
462462
request = request.with_header(key, value);
463463
}
@@ -493,4 +493,4 @@ impl Sleeper for DefaultSleeper {
493493
fn sleep(dur: std::time::Duration) -> Self::Sleep {
494494
tokio::time::sleep(dur)
495495
}
496-
}
496+
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub enum Error {
201201
#[cfg(feature = "blocking")]
202202
Minreq(::minreq::Error),
203203
/// Error during async_minreq HTTP request
204-
#[cfg(feature = "async")]
204+
#[cfg(feature = "async")]
205205
AsyncMinreq(async_minreq::Error),
206206
/// JSON Error
207207
Json(serde_json::Error),
@@ -1087,4 +1087,4 @@ mod test {
10871087
assert_eq!(address_txs_blocking, address_txs_async);
10881088
assert_eq!(address_txs_async[0].txid, txid);
10891089
}
1090-
}
1090+
}

0 commit comments

Comments
 (0)