commit
72f278efed
@ -1 +1 @@
|
||||
Subproject commit e8f4624b7f1a15c63674eecf577c7ab76c3b16be
|
||||
Subproject commit 9028c4801fd39fbb71a9796979182549a24e81c8
|
@ -179,7 +179,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
let snapshot_path = db_dirs.snapshot_path();
|
||||
|
||||
// execute upgrades
|
||||
try!(execute_upgrades(&db_dirs, algorithm, cmd.compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
try!(execute_upgrades(&cmd.dirs.base, &db_dirs, algorithm, cmd.compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
|
||||
// create dirs used by parity
|
||||
try!(cmd.dirs.create_dirs(false, false));
|
||||
@ -348,7 +348,7 @@ fn start_client(
|
||||
let snapshot_path = db_dirs.snapshot_path();
|
||||
|
||||
// execute upgrades
|
||||
try!(execute_upgrades(&db_dirs, algorithm, compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
try!(execute_upgrades(&dirs.base, &db_dirs, algorithm, compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
|
||||
// create dirs used by parity
|
||||
try!(dirs.create_dirs(false, false));
|
||||
|
@ -8,7 +8,8 @@ no_download = false
|
||||
no_consensus = false
|
||||
|
||||
chain = "homestead"
|
||||
db_path = "$HOME/.parity"
|
||||
base_path = "$HOME/.parity"
|
||||
db_path = "$HOME/.parity/chains"
|
||||
keys_path = "$HOME/.parity/keys"
|
||||
identity = ""
|
||||
|
||||
|
@ -90,8 +90,9 @@ usage! {
|
||||
flag_no_download: bool = false, or |c: &Config| otry!(c.parity).no_download.clone(),
|
||||
flag_no_consensus: bool = false, or |c: &Config| otry!(c.parity).no_consensus.clone(),
|
||||
flag_chain: String = "homestead", or |c: &Config| otry!(c.parity).chain.clone(),
|
||||
flag_db_path: String = default_data_path(), or |c: &Config| otry!(c.parity).db_path.clone(),
|
||||
flag_keys_path: String = "$DATA/keys", or |c: &Config| otry!(c.parity).keys_path.clone(),
|
||||
flag_base_path: String = default_data_path(), or |c: &Config| otry!(c.parity).base_path.clone(),
|
||||
flag_db_path: String = "$BASE/chains", or |c: &Config| otry!(c.parity).db_path.clone(),
|
||||
flag_keys_path: String = "$BASE/keys", or |c: &Config| otry!(c.parity).keys_path.clone(),
|
||||
flag_identity: String = "", or |c: &Config| otry!(c.parity).identity.clone(),
|
||||
|
||||
// -- Account Options
|
||||
@ -110,7 +111,7 @@ usage! {
|
||||
or |c: &Config| otry!(c.ui).port.clone(),
|
||||
flag_ui_interface: String = "local",
|
||||
or |c: &Config| otry!(c.ui).interface.clone(),
|
||||
flag_ui_path: String = "$DATA/signer",
|
||||
flag_ui_path: String = "$BASE/signer",
|
||||
or |c: &Config| otry!(c.ui).path.clone(),
|
||||
// NOTE [todr] For security reasons don't put this to config files
|
||||
flag_ui_no_validation: bool = false, or |_| None,
|
||||
@ -166,7 +167,7 @@ usage! {
|
||||
// IPC
|
||||
flag_no_ipc: bool = false,
|
||||
or |c: &Config| otry!(c.ipc).disable.clone(),
|
||||
flag_ipc_path: String = "$DATA/jsonrpc.ipc",
|
||||
flag_ipc_path: String = "$BASE/jsonrpc.ipc",
|
||||
or |c: &Config| otry!(c.ipc).path.clone(),
|
||||
flag_ipc_apis: String = "web3,eth,net,parity,parity_accounts,traces,rpc",
|
||||
or |c: &Config| otry!(c.ipc).apis.clone().map(|vec| vec.join(",")),
|
||||
@ -180,7 +181,7 @@ usage! {
|
||||
or |c: &Config| otry!(c.dapps).interface.clone(),
|
||||
flag_dapps_hosts: String = "none",
|
||||
or |c: &Config| otry!(c.dapps).hosts.clone().map(|vec| vec.join(",")),
|
||||
flag_dapps_path: String = "$DATA/dapps",
|
||||
flag_dapps_path: String = "$BASE/dapps",
|
||||
or |c: &Config| otry!(c.dapps).path.clone(),
|
||||
flag_dapps_user: Option<String> = None,
|
||||
or |c: &Config| otry!(c.dapps).user.clone().map(Some),
|
||||
@ -281,7 +282,7 @@ usage! {
|
||||
or |c: &Config| otry!(c.vm).jit.clone(),
|
||||
|
||||
// -- Miscellaneous Options
|
||||
flag_config: String = "$DATA/config.toml", or |_| None,
|
||||
flag_config: String = "$BASE/config.toml", or |_| None,
|
||||
flag_logging: Option<String> = None,
|
||||
or |c: &Config| otry!(c.misc).logging.clone().map(Some),
|
||||
flag_log_file: Option<String> = None,
|
||||
@ -318,6 +319,7 @@ struct Operating {
|
||||
no_download: Option<bool>,
|
||||
no_consensus: Option<bool>,
|
||||
chain: Option<String>,
|
||||
base_path: Option<String>,
|
||||
db_path: Option<String>,
|
||||
keys_path: Option<String>,
|
||||
identity: Option<String>,
|
||||
@ -546,7 +548,8 @@ mod tests {
|
||||
flag_no_download: false,
|
||||
flag_no_consensus: false,
|
||||
flag_chain: "xyz".into(),
|
||||
flag_db_path: "$HOME/.parity".into(),
|
||||
flag_base_path: "$HOME/.parity".into(),
|
||||
flag_db_path: "$HOME/.parity/chains".into(),
|
||||
flag_keys_path: "$HOME/.parity/keys".into(),
|
||||
flag_identity: "".into(),
|
||||
|
||||
@ -688,7 +691,7 @@ mod tests {
|
||||
|
||||
// -- Miscellaneous Options
|
||||
flag_version: false,
|
||||
flag_config: "$DATA/config.toml".into(),
|
||||
flag_config: "$BASE/config.toml".into(),
|
||||
flag_logging: Some("own_tx=trace".into()),
|
||||
flag_log_file: Some("/var/log/parity.log".into()),
|
||||
flag_no_color: false,
|
||||
@ -724,6 +727,7 @@ mod tests {
|
||||
no_download: None,
|
||||
no_consensus: None,
|
||||
chain: Some("./chain.json".into()),
|
||||
base_path: None,
|
||||
db_path: None,
|
||||
keys_path: None,
|
||||
identity: None,
|
||||
|
@ -59,7 +59,9 @@ Operating Options:
|
||||
JSON chain specification file or olympic, frontier,
|
||||
homestead, mainnet, morden, ropsten, classic, expanse,
|
||||
testnet or dev (default: {flag_chain}).
|
||||
-d --db-path PATH Specify the database & configuration directory path
|
||||
-d --base-path PATH Specify the base data storage path.
|
||||
(default: {flag_base_path}).
|
||||
--db-path PATH Specify the database directory path
|
||||
(default: {flag_db_path}).
|
||||
--keys-path PATH Specify the path for JSON key files to be found
|
||||
(default: {flag_keys_path}).
|
||||
|
@ -592,7 +592,7 @@ impl Configuration {
|
||||
ret.snapshot_peers = self.snapshot_peers();
|
||||
ret.allow_ips = try!(self.allow_ips());
|
||||
ret.max_pending_peers = self.max_pending_peers();
|
||||
let mut net_path = PathBuf::from(self.directories().data);
|
||||
let mut net_path = PathBuf::from(self.directories().base);
|
||||
net_path.push("network");
|
||||
ret.config_path = Some(net_path.to_str().unwrap().to_owned());
|
||||
ret.reserved_nodes = try!(self.init_reserved_nodes());
|
||||
@ -708,8 +708,9 @@ impl Configuration {
|
||||
fn directories(&self) -> Directories {
|
||||
use util::path;
|
||||
|
||||
let data_path = replace_home("", self.args.flag_datadir.as_ref().unwrap_or(&self.args.flag_db_path));
|
||||
let data_path = replace_home("", self.args.flag_datadir.as_ref().unwrap_or(&self.args.flag_base_path));
|
||||
|
||||
let db_path = replace_home(&data_path, &self.args.flag_db_path);
|
||||
let keys_path = replace_home(&data_path, &self.args.flag_keys_path);
|
||||
let dapps_path = replace_home(&data_path, &self.args.flag_dapps_path);
|
||||
let ui_path = replace_home(&data_path, &self.args.flag_ui_path);
|
||||
@ -731,7 +732,8 @@ impl Configuration {
|
||||
|
||||
Directories {
|
||||
keys: keys_path,
|
||||
data: data_path,
|
||||
base: data_path,
|
||||
db: db_path,
|
||||
dapps: dapps_path,
|
||||
signer: ui_path,
|
||||
}
|
||||
@ -741,7 +743,7 @@ impl Configuration {
|
||||
if self.args.flag_geth {
|
||||
geth_ipc_path(self.args.flag_testnet)
|
||||
} else {
|
||||
parity_ipc_path(&self.directories().data, &self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone()))
|
||||
parity_ipc_path(&self.directories().base, &self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ impl Default for Configuration {
|
||||
hosts: Some(Vec::new()),
|
||||
user: None,
|
||||
pass: None,
|
||||
dapps_path: replace_home(&data_dir, "$DATA/dapps"),
|
||||
dapps_path: replace_home(&data_dir, "$BASE/dapps"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ const LEGACY_CLIENT_DB_VER_STR: &'static str = "5.3";
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Directories {
|
||||
pub data: String,
|
||||
pub base: String,
|
||||
pub db: String,
|
||||
pub keys: String,
|
||||
pub signer: String,
|
||||
pub dapps: String,
|
||||
@ -37,17 +38,19 @@ impl Default for Directories {
|
||||
fn default() -> Self {
|
||||
let data_dir = default_data_path();
|
||||
Directories {
|
||||
data: replace_home(&data_dir, "$DATA"),
|
||||
keys: replace_home(&data_dir, "$DATA/keys"),
|
||||
signer: replace_home(&data_dir, "$DATA/signer"),
|
||||
dapps: replace_home(&data_dir, "$DATA/dapps"),
|
||||
base: replace_home(&data_dir, "$BASE"),
|
||||
db: replace_home(&data_dir, "$BASE/chains"),
|
||||
keys: replace_home(&data_dir, "$BASE/keys"),
|
||||
signer: replace_home(&data_dir, "$BASE/signer"),
|
||||
dapps: replace_home(&data_dir, "$BASE/dapps"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Directories {
|
||||
pub fn create_dirs(&self, dapps_enabled: bool, signer_enabled: bool) -> Result<(), String> {
|
||||
try!(fs::create_dir_all(&self.data).map_err(|e| e.to_string()));
|
||||
try!(fs::create_dir_all(&self.base).map_err(|e| e.to_string()));
|
||||
try!(fs::create_dir_all(&self.db).map_err(|e| e.to_string()));
|
||||
try!(fs::create_dir_all(&self.keys).map_err(|e| e.to_string()));
|
||||
if signer_enabled {
|
||||
try!(fs::create_dir_all(&self.signer).map_err(|e| e.to_string()));
|
||||
@ -61,7 +64,8 @@ impl Directories {
|
||||
/// Database paths.
|
||||
pub fn database(&self, genesis_hash: H256, fork_name: Option<String>, spec_name: String) -> DatabaseDirectories {
|
||||
DatabaseDirectories {
|
||||
path: self.data.clone(),
|
||||
path: self.db.clone(),
|
||||
legacy_path: self.base.clone(),
|
||||
genesis_hash: genesis_hash,
|
||||
fork_name: fork_name,
|
||||
spec_name: spec_name,
|
||||
@ -70,14 +74,14 @@ impl Directories {
|
||||
|
||||
/// Get the ipc sockets path
|
||||
pub fn ipc_path(&self) -> PathBuf {
|
||||
let mut dir = Path::new(&self.data).to_path_buf();
|
||||
let mut dir = Path::new(&self.base).to_path_buf();
|
||||
dir.push("ipc");
|
||||
dir
|
||||
}
|
||||
|
||||
// TODO: remove in 1.7
|
||||
pub fn legacy_keys_path(&self, testnet: bool) -> PathBuf {
|
||||
let mut dir = Path::new(&self.data).to_path_buf();
|
||||
let mut dir = Path::new(&self.base).to_path_buf();
|
||||
if testnet {
|
||||
dir.push("testnet_keys");
|
||||
} else {
|
||||
@ -96,6 +100,7 @@ impl Directories {
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct DatabaseDirectories {
|
||||
pub path: String,
|
||||
pub legacy_path: String,
|
||||
pub genesis_hash: H256,
|
||||
pub fork_name: Option<String>,
|
||||
pub spec_name: String,
|
||||
@ -105,14 +110,13 @@ impl DatabaseDirectories {
|
||||
/// Base DB directory for the given fork.
|
||||
// TODO: remove in 1.7
|
||||
pub fn legacy_fork_path(&self) -> PathBuf {
|
||||
let mut dir = Path::new(&self.path).to_path_buf();
|
||||
let mut dir = Path::new(&self.legacy_path).to_path_buf();
|
||||
dir.push(format!("{:?}{}", H64::from(self.genesis_hash), self.fork_name.as_ref().map(|f| format!("-{}", f)).unwrap_or_default()));
|
||||
dir
|
||||
}
|
||||
|
||||
pub fn spec_root_path(&self) -> PathBuf {
|
||||
let mut dir = Path::new(&self.path).to_path_buf();
|
||||
dir.push("chains");
|
||||
dir.push(&self.spec_name);
|
||||
dir
|
||||
}
|
||||
@ -209,10 +213,11 @@ mod tests {
|
||||
fn test_default_directories() {
|
||||
let data_dir = super::default_data_path();
|
||||
let expected = Directories {
|
||||
data: replace_home(&data_dir, "$DATA"),
|
||||
keys: replace_home(&data_dir, "$DATA/keys"),
|
||||
signer: replace_home(&data_dir, "$DATA/signer"),
|
||||
dapps: replace_home(&data_dir, "$DATA/dapps"),
|
||||
base: replace_home(&data_dir, "$BASE"),
|
||||
db: replace_home(&data_dir, "$BASE/chains"),
|
||||
keys: replace_home(&data_dir, "$BASE/keys"),
|
||||
signer: replace_home(&data_dir, "$BASE/signer"),
|
||||
dapps: replace_home(&data_dir, "$BASE/dapps"),
|
||||
};
|
||||
assert_eq!(expected, Directories::default());
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ pub fn to_price(s: &str) -> Result<f32, String> {
|
||||
pub fn replace_home(base: &str, arg: &str) -> String {
|
||||
// the $HOME directory on mac os should be `~/Library` or `~/Library/Application Support`
|
||||
let r = arg.replace("$HOME", env::home_dir().unwrap().to_str().unwrap());
|
||||
let r = r.replace("$DATA", base );
|
||||
let r = r.replace("$BASE", base );
|
||||
r.replace("/", &::std::path::MAIN_SEPARATOR.to_string() )
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ pub fn to_bootnodes(bootnodes: &Option<String>) -> Result<Vec<String>, String> {
|
||||
pub fn default_network_config() -> ::ethsync::NetworkConfiguration {
|
||||
use ethsync::{NetworkConfiguration, AllowIP};
|
||||
NetworkConfiguration {
|
||||
config_path: Some(replace_home(&::dir::default_data_path(), "$DATA/network")),
|
||||
config_path: Some(replace_home(&::dir::default_data_path(), "$BASE/network")),
|
||||
net_config_path: None,
|
||||
listen_address: Some("0.0.0.0:30303".into()),
|
||||
public_address: None,
|
||||
@ -257,12 +257,13 @@ pub fn to_client_config(
|
||||
}
|
||||
|
||||
pub fn execute_upgrades(
|
||||
base_path: &str,
|
||||
dirs: &DatabaseDirectories,
|
||||
pruning: Algorithm,
|
||||
compaction_profile: CompactionProfile
|
||||
) -> Result<(), String> {
|
||||
|
||||
upgrade_data_paths(dirs, pruning);
|
||||
upgrade_data_paths(base_path, dirs, pruning);
|
||||
|
||||
match upgrade(Some(&dirs.path)) {
|
||||
Ok(upgrades_applied) if upgrades_applied > 0 => {
|
||||
|
@ -62,7 +62,7 @@ impl Default for IpcConfiguration {
|
||||
let data_dir = default_data_path();
|
||||
IpcConfiguration {
|
||||
enabled: true,
|
||||
socket_addr: parity_ipc_path(&data_dir, "$DATA/jsonrpc.ipc"),
|
||||
socket_addr: parity_ipc_path(&data_dir, "$BASE/jsonrpc.ipc"),
|
||||
apis: ApiSet::IpcContext,
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
||||
let snapshot_path = db_dirs.snapshot_path();
|
||||
|
||||
// execute upgrades
|
||||
try!(execute_upgrades(&db_dirs, algorithm, cmd.compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
try!(execute_upgrades(&cmd.dirs.base, &db_dirs, algorithm, cmd.compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
|
||||
// create dirs used by parity
|
||||
try!(cmd.dirs.create_dirs(cmd.dapps_conf.enabled, cmd.signer_conf.enabled));
|
||||
|
@ -44,7 +44,7 @@ impl Default for Configuration {
|
||||
enabled: true,
|
||||
port: 8180,
|
||||
interface: "127.0.0.1".into(),
|
||||
signer_path: replace_home(&data_dir, "$DATA/signer"),
|
||||
signer_path: replace_home(&data_dir, "$BASE/signer"),
|
||||
skip_origin_validation: false,
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ impl SnapshotCommand {
|
||||
let snapshot_path = db_dirs.snapshot_path();
|
||||
|
||||
// execute upgrades
|
||||
try!(execute_upgrades(&db_dirs, algorithm, self.compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
try!(execute_upgrades(&self.dirs.base, &db_dirs, algorithm, self.compaction.compaction_profile(db_dirs.db_root_path().as_path())));
|
||||
|
||||
// prepare client config
|
||||
let client_config = to_client_config(&self.cache_config, Mode::Active, tracing, fat_db, self.compaction, self.wal, VMType::default(), "".into(), algorithm, self.pruning_history, true);
|
||||
|
@ -200,11 +200,11 @@ fn upgrade_user_defaults(dirs: &DatabaseDirectories) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn upgrade_data_paths(dirs: &DatabaseDirectories, pruning: Algorithm) {
|
||||
pub fn upgrade_data_paths(base_path: &str, dirs: &DatabaseDirectories, pruning: Algorithm) {
|
||||
let legacy_root_path = replace_home("", "$HOME/.parity");
|
||||
let default_path = default_data_path();
|
||||
if legacy_root_path != dirs.path && dirs.path == default_path {
|
||||
upgrade_dir_location(&PathBuf::from(legacy_root_path), &PathBuf::from(&dirs.path));
|
||||
if legacy_root_path != base_path && base_path == default_path {
|
||||
upgrade_dir_location(&PathBuf::from(legacy_root_path), &PathBuf::from(&base_path));
|
||||
}
|
||||
upgrade_dir_location(&dirs.legacy_version_path(pruning), &dirs.db_path(pruning));
|
||||
upgrade_dir_location(&dirs.legacy_snapshot_path(), &dirs.snapshot_path());
|
||||
|
Loading…
Reference in New Issue
Block a user