Skip to content

Commit f403605

Browse files
committed
Reducing dependencies to minimum; new feature system
1 parent fd63aec commit f403605

File tree

14 files changed

+224
-297
lines changed

14 files changed

+224
-297
lines changed

Cargo.lock

Lines changed: 34 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ rgb20 = { version = "0.3.0-rc.2", optional = true }
3838
rgb21 = { version = "0.3.0-beta.3", optional = true }
3939
rgb22 = { version = "0.3.0-beta.3", optional = true }
4040
rgb23 = { version = "0.3.0-beta.3", optional = true }
41-
internet2 = "0.3.1"
42-
microservices = "0.3"
41+
internet2 = { version = "0.3.4", default-features = false, features = ["derive"] }
42+
microservices = { version = "0.3.2", default-features = false }
4343
# Bitcoin
4444
bitcoin = "0.26"
4545
electrum-client = { version = "0.5.0-beta.1", optional = true, git = "https://github.com/LNP-BP/rust-electrum-client", branch = "bitcoin-0.26" }
@@ -57,26 +57,15 @@ serde_yaml = { version = "0.8", optional = true }
5757
toml = { version = "0.5", optional = true }
5858
bech32 = { version = "0.7", optional = true }
5959
base64 = { version = "0.12", optional = true }
60-
regex = { version = "1.3", optional = true }
61-
url = { version = "2.1", optional = true }
6260
# Congig & logging
61+
log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] }
62+
env_logger = "0.7"
63+
clap = { version = "3.0.0-beta.2", optional = true }
6364
settings = { version = "0.10", package = "config", optional = true }
6465
configure_me = { version = "0.3", optional = true }
6566
dotenv = { version = "0.15", optional = true }
66-
clap = { version = "3.0.0-beta.2", optional = true }
67-
log = { version = "0.4", optional = true, features = ["max_level_trace", "release_max_level_debug"] }
68-
env_logger = { version = "0.7", optional = true }
6967
colored = { version = "2.0", optional = true }
7068
shellexpand = { version = "2.0", optional = true }
71-
# Processes & IPC
72-
zmq = { version = "0.9", optional = true }
73-
74-
[target.'cfg(target_os="android")'.dependencies]
75-
zmq = { version = "0.9", features = ["vendored"] }
76-
77-
[patch.crates-io]
78-
# Remove this once https://github.com/jean-airoldie/zeromq-src-rs/pull/15 got merged
79-
zeromq-src = { git = "https://github.com/LNP-BP/zeromq-src-rs", branch = "fix/cmake" }
8069

8170
# Recommended set of features:
8271
# 1. Standalone node: `server` (=`node`+`shell`)
@@ -85,35 +74,44 @@ zeromq-src = { git = "https://github.com/LNP-BP/zeromq-src-rs", branch = "fix/cm
8574
# 4. Mobile app with embedded node: `embedded` (auto includes `client` + `node`)
8675
# 5. Simple cli utility app: `shell`
8776
[features]
88-
default = ["client", "server", "fungibles", "collectibles", "identities", "auditlogs"]
77+
default = ["client", "fungibles"]
78+
8979
# Server is a standalone application that runs daemon
9080
server = ["node", "shell", "nix", "microservices/server"]
91-
# Feature is required for any applications that talks to daemon processes
92-
client = ["zmq", "microservices/client", "bitcoin/rand",
93-
"regex", "electrum-client", "base64",
94-
"url", "internet2/url", "log", "env_logger",
95-
# TODO: Femove the following after feature gates debugging:
96-
"clap"]
97-
# Embedded is an app that contains node in itself and that talks to it through
81+
# Command-line application feature
82+
cli = ["shell", "client", "serde", "microservices/cli"]
83+
84+
# Embedded is an app that contains embedded node and that talks to it through
9885
# integration layer
9986
embedded = ["client", "node", "microservices/embedded"]
100-
# Command-line application feature
101-
cli = ["shell", "client", "microservices/cli"]
87+
# Server node can be run as a part of mobile app and other types of clients;
88+
# thus `server` != `node`.
89+
# This feature results in building with features not required for command-line
90+
node = ["serde", "internet2/keygen", "bitcoin/rand", "internet2/zmq", "microservices/node",
91+
"internet2/url", "electrum-client", "base64",
92+
# Required for storing config and cache
93+
"_config", "_rpc"]
94+
# Feature is required for any applications that talks to daemon processes
95+
client = ["internet2/zmq", "microservices/client", "microservices/node", "bitcoin/rand",
96+
"electrum-client", "base64",
97+
"internet2/url", "clap", "_rpc"]
10298
# Required for all apps that can be launched from command-line shell as binaries
10399
# (i.e. both servers and cli)
104100
shell = [
105-
"dotenv", "clap", "settings", "configure_me", "log", "env_logger", "serde",
101+
"dotenv", "clap", "settings", "configure_me", "serde",
106102
"amplify/parse_arg", "microservices/shell", "shellexpand", "colored"
107103
]
108-
# Besides server node can be run as a part of mobile app
109-
# and other types of clients; thus `server` != `node`.
110-
# This feature results in building with features not required for CLI
111-
node = ["serde", "internet2/keygen", "bitcoin/rand", "zmq", "microservices/node",
112-
"url", "internet2/url", "regex", "electrum-client", "base64",
113-
# Required for storing config and cache
114-
"serde_yaml", "toml"]
104+
105+
# Internally used features for convenience
106+
_config = ["serde_yaml", "toml"]
107+
_rpc = []
108+
115109
serde = ["serde_crate", "serde_with", "serde_yaml", "serde_json", "toml",
116-
"amplify/serde", "lnpbp/serde", "internet2/serde", "chrono/serde", "bitcoin/serde", "rgb20/serde"]
110+
"amplify/serde", "lnpbp/serde", "internet2/serde", "microservices/serde",
111+
"chrono/serde", "bitcoin/serde", "rgb20/serde"]
112+
tor = ["microservices/tor", "internet2/tor"]
113+
vendored_openssl = ["microservices/vendored_openssl", "internet2/vendored_openssl"]
114+
117115
# Schema-specific components exposed as features:
118116
fungibles = ["rgb20"]
119117
collectibles = ["rgb21"]

src/cli/fungible.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use super::{Error, OutputFormat, Runtime};
3131
use crate::rpc::fungible::{AcceptApi, Issue, TransferApi};
3232
use crate::rpc::{reply, Reply};
3333
use crate::util::file::ReadWrite;
34-
use crate::DataFormat;
34+
use microservices::FileFormat;
3535

3636
#[derive(Clap, Clone, Debug, Display)]
3737
#[display(Debug)]
@@ -175,10 +175,11 @@ impl Command {
175175
}
176176
Reply::Sync(reply::SyncFormat(input_format, data)) => {
177177
let assets: Vec<Asset> = match input_format {
178-
DataFormat::Yaml => serde_yaml::from_slice(&data)?,
179-
DataFormat::Json => serde_json::from_slice(&data)?,
180-
DataFormat::Toml => toml::from_slice(&data)?,
181-
DataFormat::StrictEncode => strict_deserialize(&data)?,
178+
FileFormat::Yaml => serde_yaml::from_slice(&data)?,
179+
FileFormat::Json => serde_json::from_slice(&data)?,
180+
FileFormat::Toml => toml::from_slice(&data)?,
181+
FileFormat::StrictEncode => strict_deserialize(&data)?,
182+
_ => unimplemented!(),
182183
};
183184
let short: Vec<HashMap<&str, String>> = assets
184185
.iter()

src/cli/runtime.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::error::{BootstrapError, ServiceErrorDomain};
2727
use crate::rpc::fungible::{self, AcceptApi, Issue, TransferApi};
2828
use crate::rpc::stash;
2929
use crate::rpc::Reply;
30-
use crate::DataFormat;
30+
use microservices::FileFormat;
3131

3232
pub struct Runtime {
3333
stash_rpc: session::Raw<PlainTranscoder, transport::zmqsocket::Connection>,
@@ -108,10 +108,10 @@ impl Runtime {
108108
output_format: OutputFormat,
109109
) -> Result<Arc<Reply>, Error> {
110110
let data_format = match output_format {
111-
OutputFormat::Yaml => DataFormat::Yaml,
112-
OutputFormat::Json => DataFormat::Json,
113-
OutputFormat::Toml => DataFormat::Toml,
114-
OutputFormat::StrictEncode => DataFormat::StrictEncode,
111+
OutputFormat::Yaml => FileFormat::Yaml,
112+
OutputFormat::Json => FileFormat::Json,
113+
OutputFormat::Toml => FileFormat::Toml,
114+
OutputFormat::StrictEncode => FileFormat::StrictEncode,
115115
_ => unimplemented!("The provided output format is not supported for this operation")
116116
};
117117
Ok(self.fungible_command(fungible::Request::Sync(data_format))?)

0 commit comments

Comments
 (0)