From f001006fc90d2c104a381394c7a99214974c66b0 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Thu, 7 Dec 2017 19:04:17 +0000 Subject: [PATCH] Re-introduce wallet config as part of global `grin.toml` Wallet configuration was disabled presumably as wallet is its own separate process. However people seem to still want to use a single config for everything, which may be a sign that the lifecycle of the wallet and the server should be the same by default (with appropriate options to only start one). Note that this does *not* mean that the wallet and the server should share the same process. The wallet process can easily be forked. But sharing the same config file may provide a lot of future convenience. --- config/src/config.rs | 4 +++- config/src/types.rs | 11 ++++++----- src/bin/grin.rs | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/config/src/config.rs b/config/src/config.rs index 020f879d9..67e5dc21a 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -24,6 +24,7 @@ use grin::ServerConfig; use pow::types::MinerConfig; use util::LoggingConfig; use types::{ConfigError, ConfigMembers, GlobalConfig}; +use wallet::WalletConfig; /// The default file name to use when trying to derive /// the config file location @@ -39,6 +40,7 @@ impl Default for ConfigMembers { server: ServerConfig::default(), mining: Some(MinerConfig::default()), logging: Some(LoggingConfig::default()), + wallet: WalletConfig::default(), } } } @@ -133,7 +135,7 @@ impl GlobalConfig { match decoded { Ok(mut gc) => { // Put the struct back together, because the config - // file was flattened a bit + // file was flattened a bit gc.server.mining_config = gc.mining.clone(); self.using_config_file = true; self.members = Some(gc); diff --git a/config/src/types.rs b/config/src/types.rs index a4d54e158..33d0ca903 100644 --- a/config/src/types.rs +++ b/config/src/types.rs @@ -21,6 +21,7 @@ use std::fmt; use grin::ServerConfig; use pow::types::MinerConfig; use util::LoggingConfig; +use wallet::WalletConfig; /// Error type wrapping config errors. #[derive(Debug)] @@ -101,9 +102,9 @@ pub struct ConfigMembers { /// Logging config pub logging: Option, - //removing wallet from here for now, - //as its concerns are separate from the server's, really - //given it needs to manage keys. It should probably - //stay command line only for the time being - //pub wallet: Option + /// Wallet config. May eventually need to be moved to its own thing. Or not. + /// Depends on whether we end up starting the wallet in its own process but + /// with the same lifecycle as the server. + #[serde(default)] + pub wallet: WalletConfig, } diff --git a/src/bin/grin.rs b/src/bin/grin.rs index 783a7fc00..fc6b6d33c 100644 --- a/src/bin/grin.rs +++ b/src/bin/grin.rs @@ -281,7 +281,7 @@ fn main() { // client commands and options ("wallet", Some(wallet_args)) => { - wallet_command(wallet_args); + wallet_command(wallet_args, global_config); } // If nothing is specified, try to just use the config file instead @@ -368,8 +368,9 @@ fn server_command(server_args: &ArgMatches, global_config: GlobalConfig) { } } -fn wallet_command(wallet_args: &ArgMatches) { - let mut wallet_config = WalletConfig::default(); +fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) { + // just get defaults from the global config + let mut wallet_config = global_config.members.unwrap().wallet; if let Some(port) = wallet_args.value_of("port") { wallet_config.api_listen_port = port.to_string();