Skip to content

Commit

Permalink
chore(deps): replace instant with web-time (#1830)
Browse files Browse the repository at this point in the history
* chore(deps): replace `instant` with `web-time`

Close #1597

* fix build

* fix build v2

* cargo fmt
  • Loading branch information
niklasad1 authored Oct 22, 2024
1 parent c07c760 commit 418bd88
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
26 changes: 12 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ send_wrapper = "0.6.0"
js-sys = "0.3.70"
wasm-bindgen-futures = "0.4.43"
futures-timer = "3"
instant = { version = "0.1.13", default-features = false }
web-time = { version = "1.1", default-features = false }
tokio-util = "0.7.12"

# Substrate crates:
Expand Down
4 changes: 2 additions & 2 deletions lightclient/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ web = [
# For the light-client platform.
"wasm-bindgen-futures",
"futures-timer/wasm-bindgen",
"instant/wasm-bindgen",
"web-time",
"pin-project",

# For websocket.
Expand Down Expand Up @@ -66,7 +66,7 @@ wasm-bindgen-futures = { workspace = true, optional = true }
smoldot = { workspace = true, optional = true }
pin-project = { workspace = true, optional = true }
futures-timer = { workspace = true, optional = true }
instant = { workspace = true, optional = true }
web-time = { workspace = true, optional = true }
getrandom = { workspace = true, optional = true }

[package.metadata.docs.rs]
Expand Down
8 changes: 4 additions & 4 deletions lightclient/src/platform/wasm_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use core::time::Duration;
use futures_util::{future, FutureExt};

pub fn now_from_unix_epoch() -> Duration {
instant::SystemTime::now()
.duration_since(instant::SystemTime::UNIX_EPOCH)
web_time::SystemTime::now()
.duration_since(web_time::SystemTime::UNIX_EPOCH)
.unwrap_or_else(|_| {
panic!("Invalid systime cannot be configured earlier than `UNIX_EPOCH`")
})
}

pub type Instant = instant::Instant;
pub type Instant = web_time::Instant;

pub fn now() -> Instant {
instant::Instant::now()
web_time::Instant::now()
}

pub type Delay = future::BoxFuture<'static, ()>;
Expand Down
3 changes: 1 addition & 2 deletions subxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ web = [
"getrandom/js",
"subxt-lightclient?/web",
"subxt-macro/web",
"instant/wasm-bindgen",
"tokio?/sync",
"finito?/wasm-bindgen",
]
Expand Down Expand Up @@ -99,7 +98,7 @@ thiserror = { workspace = true }
tracing = { workspace = true }
frame-metadata = { workspace = true }
either = { workspace = true }
instant = { workspace = true }
web-time = { workspace = true }

# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/backend/chain_head/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for ChainHeadBackend<T> {
let mut finalized_hash: Option<T::Hash> = None;

// Record the start time so that we can time out if things appear to take too long.
let start_instant = instant::Instant::now();
let start_instant = web_time::Instant::now();

// A quick helper to return a generic error.
let err_other = |s: &str| Some(Err(Error::Other(s.into())));
Expand Down

0 comments on commit 418bd88

Please sign in to comment.