Skip to content

Commit c957bab

Browse files
committed
adapt-wasm32-without-fmt
1 parent 63f41fd commit c957bab

File tree

25 files changed

+62
-37
lines changed

25 files changed

+62
-37
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ resolver = "2"
55
# as in `ci/ci-tests.sh`.
66
members = [
77
"lightning",
8+
"lightning-common",
89
"lightning-types",
910
"lightning-block-sync",
1011
"lightning-invoice",

lightning-background-processor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ bitcoin_hashes = { version = "0.14.0", default-features = false }
2525
bitcoin-io = { version = "0.1.2", default-features = false }
2626
lightning = { version = "0.1.0", path = "../lightning", default-features = false }
2727
lightning-rapid-gossip-sync = { version = "0.1.0", path = "../lightning-rapid-gossip-sync", default-features = false }
28+
lightning-common = { path = "../lightning-common" }
2829

2930
[dev-dependencies]
3031
tokio = { version = "1.35", features = [ "macros", "rt", "rt-multi-thread", "sync", "time" ] }

lightning-background-processor/src/lib.rs

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

5757
#[cfg(not(feature = "std"))]
5858
use alloc::boxed::Box;
@@ -948,7 +948,7 @@ impl BackgroundProcessor {
948948
handle_network_graph_update(network_graph, &event)
949949
}
950950
if let Some(ref scorer) = scorer {
951-
use std::time::SystemTime;
951+
use lightning_common::SystemTime;
952952
let duration_since_epoch = SystemTime::now()
953953
.duration_since(SystemTime::UNIX_EPOCH)
954954
.expect("Time should be sometime after 1970");
@@ -995,7 +995,7 @@ impl BackgroundProcessor {
995995
|time: &Instant, dur| time.elapsed().as_secs() > dur,
996996
false,
997997
|| {
998-
use std::time::SystemTime;
998+
use lightning_common::SystemTime;
999999
Some(
10001000
SystemTime::now()
10011001
.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
@@ -20,6 +20,7 @@ std = []
2020
[dependencies]
2121
bech32 = { version = "0.11.0", default-features = false }
2222
lightning-types = { version = "0.2.0", path = "../lightning-types", default-features = false }
23+
lightning-common = { path = "../lightning-common" }
2324
serde = { version = "1.0.118", optional = true }
2425
bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
2526

lightning-invoice/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern crate lightning_types;
2828
extern crate serde;
2929

3030
#[cfg(feature = "std")]
31-
use std::time::SystemTime;
31+
use lightning_common::SystemTime;
3232

3333
use bech32::primitives::decode::CheckedHrpstringError;
3434
use bech32::{Checksum, Fe32};

lightning-rapid-gossip-sync/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ std = ["bitcoin-io/std", "bitcoin_hashes/std"]
1515

1616
[dependencies]
1717
lightning = { version = "0.1.0", path = "../lightning", default-features = false }
18+
lightning-common = { path = "../lightning-common" }
1819
bitcoin = { version = "0.32.2", default-features = false }
1920
bitcoin_hashes = { version = "0.14.0", default-features = false }
2021
bitcoin-io = { version = "0.1.2", default-features = false }

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
@@ -25,6 +25,7 @@ async-interface = []
2525
[dependencies]
2626
lightning = { version = "0.1.0", path = "../lightning", default-features = false, features = ["std"] }
2727
lightning-macros = { version = "0.1", path = "../lightning-macros", default-features = false }
28+
lightning-common = { path = "../lightning-common" }
2829
bitcoin = { version = "0.32.2", default-features = false }
2930
futures = { version = "0.3", optional = true }
3031
esplora-client = { version = "0.11", default-features = false, optional = true }

0 commit comments

Comments
 (0)