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.
This commit is contained in:
Ignotus Peverell 2017-12-07 19:04:17 +00:00
parent 1ac8aa9978
commit f001006fc9
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
3 changed files with 13 additions and 9 deletions

View file

@ -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);

View file

@ -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<LoggingConfig>,
//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<WalletConfig>
/// 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,
}

View file

@ -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();