Skip to content

Commit 973d9cd

Browse files
committed
adapt-wasm32-without-fmt
1 parent e80d632 commit 973d9cd

File tree

26 files changed

+66
-41
lines changed

26 files changed

+66
-41
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33

44
members = [
55
"lightning",
6+
"lightning-common",
67
"lightning-types",
78
"lightning-block-sync",
89
"lightning-invoice",

lightning-background-processor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ default = ["std"]
2222

2323
[dependencies]
2424
bitcoin = { version = "0.32.2", default-features = false }
25+
lightning-common = { path = "../lightning-common" }
2526
lightning = { version = "0.0.125", path = "../lightning", default-features = false }
2627
lightning-rapid-gossip-sync = { version = "0.0.125", path = "../lightning-rapid-gossip-sync", default-features = false }
2728

lightning-background-processor/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ use core::time::Duration;
4949
#[cfg(feature = "std")]
5050
use core::sync::atomic::{AtomicBool, Ordering};
5151
#[cfg(feature = "std")]
52+
use lightning_common::Instant;
53+
#[cfg(feature = "std")]
5254
use std::sync::Arc;
5355
#[cfg(feature = "std")]
5456
use std::thread::{self, JoinHandle};
55-
#[cfg(feature = "std")]
56-
use std::time::Instant;
5757

5858
#[cfg(not(feature = "std"))]
5959
use alloc::boxed::Box;
@@ -949,7 +949,7 @@ impl BackgroundProcessor {
949949
handle_network_graph_update(network_graph, &event)
950950
}
951951
if let Some(ref scorer) = scorer {
952-
use std::time::SystemTime;
952+
use lightning_common::SystemTime;
953953
let duration_since_epoch = SystemTime::now()
954954
.duration_since(SystemTime::UNIX_EPOCH)
955955
.expect("Time should be sometime after 1970");
@@ -996,7 +996,7 @@ impl BackgroundProcessor {
996996
|time: &Instant, dur| time.elapsed().as_secs() > dur,
997997
false,
998998
|| {
999-
use std::time::SystemTime;
999+
use lightning_common::SystemTime;
10001000
Some(
10011001
SystemTime::now()
10021002
.duration_since(SystemTime::UNIX_EPOCH)

lightning-common/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "lightning-common"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
8+
[target.'cfg(target_arch = "wasm32")'.dependencies]
9+
web-time = "1.1"
10+
11+
[lints]
12+
workspace = true

lightning-common/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[cfg(not(target_arch = "wasm32"))]
2+
pub use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
3+
#[cfg(target_arch = "wasm32")]
4+
pub use web_time::{Duration, Instant, SystemTime, UNIX_EPOCH};

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ std = []
1919

2020
[dependencies]
2121
bech32 = { version = "0.9.1", default-features = false }
22+
lightning-common = { path = "../lightning-common" }
2223
lightning-types = { version = "0.1.0", path = "../lightning-types", default-features = false }
2324
serde = { version = "1.0.118", optional = true }
2425
bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }

lightning-invoice/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern crate core;
3131
extern crate serde;
3232

3333
#[cfg(feature = "std")]
34-
use std::time::SystemTime;
34+
use lightning_common::SystemTime;
3535

3636
use bech32::{FromBase32, u5};
3737
use bitcoin::{Address, Network, PubkeyHash, ScriptHash, WitnessProgram, WitnessVersion};

lightning-rapid-gossip-sync/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ default = ["std"]
1818
std = []
1919

2020
[dependencies]
21+
lightning-common = { path = "../lightning-common" }
2122
lightning = { version = "0.0.125", path = "../lightning", default-features = false }
2223
bitcoin = { version = "0.32.2", default-features = false }
2324

lightning-rapid-gossip-sync/src/processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use lightning::{log_debug, log_given_level, log_gossip, log_trace, log_warn};
1818
use crate::{GraphSyncError, RapidGossipSync};
1919

2020
#[cfg(all(feature = "std", not(test)))]
21-
use std::time::{SystemTime, UNIX_EPOCH};
21+
use lightning_common::{SystemTime, UNIX_EPOCH};
2222

2323
#[cfg(all(not(feature = "std"), not(test)))]
2424
use alloc::{borrow::ToOwned, vec::Vec};

lightning-transaction-sync/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ electrum = ["electrum-client"]
2323
async-interface = []
2424

2525
[dependencies]
26+
lightning-common = { path = "../lightning-common" }
2627
lightning = { version = "0.0.125", path = "../lightning", default-features = false, features = ["std"] }
2728
bitcoin = { version = "0.32.2", default-features = false }
2829
bdk-macros = "0.6"

0 commit comments

Comments
 (0)