Skip to content

Commit db8acc0

Browse files
committed
refactor(async)!: use tokio::time instead of async-std::task
1 parent 1f4acad commit db8acc0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ path = "src/lib.rs"
2020
serde = { version = "1.0", features = ["derive"] }
2121
bitcoin = { version = "0.32", features = ["serde", "std"], default-features = false }
2222
hex = { version = "0.2", package = "hex-conservative" }
23-
log = "^0.4"
23+
log = { version = "^0.4" }
2424
minreq = { version = "2.11.0", features = ["json-using-serde"], optional = true }
2525
reqwest = { version = "0.11", features = ["json"], default-features = false, optional = true }
26-
async-std = { version = "1.13.0", optional = true }
26+
tokio = { version = "1.41.0", features = ["time"], default-features = false, optional = true }
2727

2828
[dev-dependencies]
2929
serde_json = "1.0"
30-
tokio = { version = "1.20.1", features = ["full"] }
30+
tokio = { version = "1.41.0", features = ["full"] }
3131
electrsd = { version = "0.28.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
3232
lazy_static = "1.4.0"
3333

3434
[features]
35-
default = ["blocking", "async", "async-https"]
35+
default = ["blocking", "async", "async-https", "tokio"]
3636
blocking = ["minreq", "minreq/proxy"]
3737
blocking-https = ["blocking", "minreq/https"]
3838
blocking-https-rustls = ["blocking", "minreq/https-rustls"]
3939
blocking-https-native = ["blocking", "minreq/https-native"]
4040
blocking-https-bundled = ["blocking", "minreq/https-bundled"]
41-
async = ["async-std", "reqwest", "reqwest/socks"]
41+
async = ["reqwest", "reqwest/socks", "tokio?/time"]
4242
async-https = ["async", "reqwest/default-tls"]
4343
async-https-native = ["async", "reqwest/native-tls"]
4444
async-https-rustls = ["async", "reqwest/rustls-tls"]

src/async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
//! Esplora by way of `reqwest` HTTP client.
1313
14-
use async_std::task;
1514
use std::collections::HashMap;
1615
use std::str::FromStr;
1716

@@ -434,7 +433,8 @@ impl AsyncClient {
434433
loop {
435434
match self.client.get(url).send().await? {
436435
resp if attempts < self.max_retries && is_status_retryable(resp.status()) => {
437-
task::sleep(delay).await;
436+
tokio::time::sleep(delay).await;
437+
// FIXME: use an sleeper_fn passed as parameter.
438438
attempts += 1;
439439
delay *= 2;
440440
}

0 commit comments

Comments
 (0)