Skip to content

Commit 2e6d021

Browse files
committed
fix Instant::now(), use web_time.
1 parent afddf1b commit 2e6d021

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mutiny-core/src/storage.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ use serde::{Deserialize, Serialize};
2828
use serde_json::Value;
2929
use std::collections::{BTreeSet, HashMap};
3030
use std::sync::{Arc, RwLock};
31+
#[cfg(not(target_arch = "wasm32"))]
32+
use std::time::Instant;
3133
use uuid::Uuid;
34+
#[cfg(target_arch = "wasm32")]
35+
use web_time::Instant;
3236

3337
pub const SUBSCRIPTION_TIMESTAMP: &str = "subscription_timestamp";
3438
pub const KEYCHAIN_STORE_KEY: &str = "bdk_keychain";
@@ -241,7 +245,7 @@ pub trait MutinyStorage: Clone + Sized + Send + Sync + 'static {
241245
}
242246

243247
// save to VSS by spawn an async task
244-
log_debug!(self.logger(), "writing to VSS");
248+
log_debug!(self.logger(), "writing to VSS {:?}", key);
245249
if let Some(cb) = self.ln_event_callback().as_ref() {
246250
let event = CommonLnEvent::SyncToVssStarting {
247251
key: key.clone(),
@@ -250,7 +254,7 @@ pub trait MutinyStorage: Clone + Sized + Send + Sync + 'static {
250254
};
251255
cb.trigger(event);
252256
}
253-
let start = std::time::Instant::now();
257+
let start = Instant::now();
254258
self.spawn({
255259
let db = self.clone();
256260
let logger = self.logger().clone();
@@ -259,7 +263,8 @@ pub trait MutinyStorage: Clone + Sized + Send + Sync + 'static {
259263
let duration = start.elapsed();
260264
log_debug!(
261265
logger,
262-
"done writing to VSS, took {:?}",
266+
"done writing to VSS {:?}, took {:?}ms",
267+
key,
263268
duration.as_millis()
264269
);
265270
if let Some(cb) = db.ln_event_callback().as_ref() {

0 commit comments

Comments
 (0)