From cc8844671773e2fbfe0c17fdf504ff2bed769413 Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 8 Dec 2022 09:07:45 +0100 Subject: [PATCH 1/3] deps: make libc optional libc dependency is only use by the lianad binary it is not needed for liana-gui. This commit makes the dependency optional by introducing a new default feature named daemon. liana/src/daemonize.rs is still compiling because the feature daemon is marked as required for the lianad binary. --- Cargo.toml | 7 ++++--- src/lib.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9258c5c8..f0834b82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ exclude = [".github/", ".cirrus.yml", "tests/", "test_data/", "contrib/", "pypr [[bin]] name = "lianad" path = "src/bin/daemon.rs" -required-features = ["jsonrpc_server"] +required-features = ["jsonrpc_server", "daemon"] [[bin]] name = "liana-cli" @@ -20,8 +20,9 @@ path = "src/bin/cli.rs" required-features = ["jsonrpc_server"] [features] -default = ["jsonrpc_server"] +default = ["jsonrpc_server", "daemon"] jsonrpc_server = [] +daemon = ["libc"] [dependencies] # For managing transactions (it re-exports the bitcoin crate) @@ -52,7 +53,7 @@ rusqlite = { version = "0.26.3", features = ["bundled", "unlock_notify"] } jsonrpc = "0.12" # Used for daemonization -libc = "0.2" +libc = { version = "0.2", optional = true } # Used for PSBTs base64 = "0.13" diff --git a/src/lib.rs b/src/lib.rs index bee7934d..dabc616f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ mod bitcoin; pub mod commands; pub mod config; -#[cfg(unix)] +#[cfg(all(unix, feature = "daemon"))] mod daemonize; mod database; pub mod descriptors; @@ -381,7 +381,7 @@ impl DaemonHandle { // If we are on a UNIX system and they told us to daemonize, do it now. // NOTE: it's safe to daemonize now, as we don't carry any open DB connection // https://www.sqlite.org/howtocorrupt.html#_carrying_an_open_database_connection_across_a_fork_ - #[cfg(unix)] + #[cfg(all(unix, feature = "daemon"))] if config.daemon { log::info!("Daemonizing"); let log_file = data_dir.as_path().join("log"); From 6ea9ba5c1c661eb26edd17212dd34459a006a981 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 24 Mar 2023 17:46:37 +0100 Subject: [PATCH 2/3] Cargo: get rid of the jsonrpc_server feature. It implies daemon. (Also, it needed libc.) --- Cargo.toml | 7 +++---- src/lib.rs | 6 +++--- src/testutils.rs | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f0834b82..24fe82b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,16 +12,15 @@ exclude = [".github/", ".cirrus.yml", "tests/", "test_data/", "contrib/", "pypr [[bin]] name = "lianad" path = "src/bin/daemon.rs" -required-features = ["jsonrpc_server", "daemon"] +required-features = ["daemon"] [[bin]] name = "liana-cli" path = "src/bin/cli.rs" -required-features = ["jsonrpc_server"] +required-features = ["daemon"] [features] -default = ["jsonrpc_server", "daemon"] -jsonrpc_server = [] +default = ["daemon"] daemon = ["libc"] [dependencies] diff --git a/src/lib.rs b/src/lib.rs index dabc616f..19f78541 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ pub mod config; mod daemonize; mod database; pub mod descriptors; -#[cfg(feature = "jsonrpc_server")] +#[cfg(feature = "daemon")] mod jsonrpc; mod random; pub mod signer; @@ -16,7 +16,7 @@ pub use bip39; pub use miniscript; pub use crate::bitcoin::d::{BitcoindError, WalletError}; -#[cfg(feature = "jsonrpc_server")] +#[cfg(feature = "daemon")] use crate::jsonrpc::server::{rpcserver_loop, rpcserver_setup}; use crate::{ bitcoin::{d::BitcoinD, poller, BitcoinInterface}, @@ -417,7 +417,7 @@ impl DaemonHandle { /// Start the JSONRPC server and listen for incoming commands until we die. /// Like DaemonHandle::shutdown(), this stops the Bitcoin poller at teardown. - #[cfg(feature = "jsonrpc_server")] + #[cfg(feature = "daemon")] pub fn rpc_server(self) -> Result<(), io::Error> { let DaemonHandle { control, diff --git a/src/testutils.rs b/src/testutils.rs index dcdb1018..400141a6 100644 --- a/src/testutils.rs +++ b/src/testutils.rs @@ -416,7 +416,7 @@ impl DummyLiana { DummyLiana { tmp_dir, handle } } - #[cfg(feature = "jsonrpc_server")] + #[cfg(feature = "daemon")] pub fn rpc_server(self) -> Result<(), io::Error> { self.handle.rpc_server()?; fs::remove_dir_all(&self.tmp_dir)?; From 4bf5234ce97fa725c076be628c12b7289466c1f1 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 24 Mar 2023 17:48:32 +0100 Subject: [PATCH 3/3] Cargo.lock: update libc --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fee56107..e4a1dc7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -244,9 +244,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.135" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libsqlite3-sys"