Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace instant dependency with web-time #1098

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion 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 mutiny-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ wasm-bindgen-futures = { version = "0.4.38" }
web-sys = { version = "0.3.65", features = ["console"] }
js-sys = "0.3.65"
gloo-net = { version = "0.4.0" }
instant = { version = "0.1", features = ["wasm-bindgen"] }
web-time = "1.1"
getrandom = { version = "0.2", features = ["js"] }
# add nip07 feature for wasm32
nostr = { version = "0.29.0", default-features = false, features = ["nip04", "nip05", "nip07", "nip47", "nip57"] }
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ use fedimint_wallet_client::{WalletClientInit, WalletClientModule};
use futures::future::{self};
use futures_util::{pin_mut, StreamExt};
use hex_conservative::{DisplayHex, FromHex};
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use lightning::{
ln::PaymentHash, log_debug, log_error, log_info, log_trace, log_warn, util::logger::Logger,
};
Expand All @@ -71,6 +69,8 @@ use std::{
str::FromStr,
sync::atomic::{AtomicU32, Ordering},
};
#[cfg(target_arch = "wasm32")]
use web_time::Instant;

// The amount of time in milliseconds to wait for
// checking the status of a fedimint payment. This
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use crate::{
use bitcoin::hashes::hex::FromHex;
use bitcoin::Network;
use hex_conservative::DisplayHex;
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use lightning::ln::msgs::NodeAnnouncement;
use lightning::routing::gossip::NodeId;
use lightning::util::logger::Logger;
Expand All @@ -20,6 +18,8 @@ use std::str::FromStr;
use std::sync::Arc;
#[cfg(not(target_arch = "wasm32"))]
use std::time::Instant;
#[cfg(target_arch = "wasm32")]
use web_time::Instant;

use crate::logging::MutinyLogger;
use crate::node::{NetworkGraph, RapidGossipSync};
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ use fedimint_core::{api::InviteCode, config::FederationId};
use futures::{pin_mut, select, FutureExt};
use futures_util::join;
use hex_conservative::{DisplayHex, FromHex};
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use itertools::Itertools;
use lightning::chain::BestBlock;
use lightning::ln::PaymentHash;
Expand All @@ -120,6 +118,8 @@ use std::time::Instant;
use std::{collections::HashMap, sync::atomic::AtomicBool};
use std::{str::FromStr, sync::atomic::Ordering};
use uuid::Uuid;
#[cfg(target_arch = "wasm32")]
use web_time::Instant;

use crate::labels::LabelItem;
use crate::nostr::NostrKeySource;
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use core::time::Duration;
use esplora_client::AsyncClient;
use futures_util::lock::Mutex;
use hex_conservative::DisplayHex;
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use lightning::events::bump_transaction::{BumpTransactionEventHandler, Wallet};
use lightning::ln::channelmanager::ChannelDetails;
use lightning::ln::PaymentSecret;
Expand Down Expand Up @@ -92,6 +90,8 @@ use std::{
Arc, RwLock,
},
};
#[cfg(target_arch = "wasm32")]
use web_time::Instant;

const INITIAL_RECONNECTION_DELAY: u64 = 10;
const MAX_RECONNECTION_DELAY: u64 = 60;
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ use core::time::Duration;
use esplora_client::{AsyncClient, Builder};
use futures::{future::join_all, lock::Mutex};
use hex_conservative::DisplayHex;
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use lightning::chain::Confirm;
use lightning::events::ClosureReason;
use lightning::ln::channelmanager::{ChannelDetails, PhantomRouteHints};
Expand All @@ -65,6 +63,8 @@ use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(not(target_arch = "wasm32"))]
use std::time::Instant;
use std::{collections::HashMap, ops::Deref, sync::Arc};
#[cfg(target_arch = "wasm32")]
use web_time::Instant;

const BITCOIN_PRICE_CACHE_SEC: u64 = 300;
pub const DEVICE_LOCK_INTERVAL_SECS: u64 = 30;
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub async fn sleep(millis: i32) {
}
pub fn now() -> Duration {
#[cfg(target_arch = "wasm32")]
return instant::SystemTime::now()
.duration_since(instant::SystemTime::UNIX_EPOCH)
return web_time::SystemTime::now()
.duration_since(web_time::SystemTime::UNIX_EPOCH)
.unwrap();

#[cfg(not(target_arch = "wasm32"))]
Expand Down
Loading