Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

standalone dir crate, replaces #7383 #7409

Merged
merged 6 commits into from
Dec 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ parity-updater = { path = "updater" }
parity-version = { path = "util/version" }
parity-whisper = { path = "whisper" }
path = { path = "util/path" }
dir = { path = "util/dir" }
panic_hook = { path = "panic_hook" }
keccak-hash = { path = "util/hash" }
migration = { path = "util/migration" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/account_provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use ethstore::{
SimpleSecretStore, SecretStore, Error as SSError, EthStore, EthMultiStore,
random_string, SecretVaultRef, StoreAccountRef, OpaqueSecret,
};
use ethstore::dir::MemoryDirectory;
use ethstore::accounts_dir::MemoryDirectory;
use ethstore::ethkey::{Address, Message, Public, Secret, Random, Generator};
use ethjson::misc::AccountMeta;
use hardware_wallet::{Error as HardwareError, HardwareWalletManager, KeyPath, TransactionInfo};
Expand Down
1 change: 1 addition & 0 deletions ethstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ itertools = "0.5"
parking_lot = "0.4"
ethcrypto = { path = "../ethcrypto" }
ethcore-bigint = { path = "../util/bigint" }
dir = { path = "../util/dir" }
smallvec = "0.4"
parity-wordlist = "1.0"
tempdir = "0.3"
Expand Down
1 change: 1 addition & 0 deletions ethstore/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ serde = "1.0"
serde_derive = "1.0"
parking_lot = "0.4"
ethstore = { path = "../" }
dir = { path = '../../util/dir' }
panic_hook = { path = "../../panic_hook" }

[[bin]]
Expand Down
9 changes: 5 additions & 4 deletions ethstore/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

extern crate dir;
extern crate docopt;
extern crate ethstore;
extern crate num_cpus;
Expand All @@ -30,7 +31,7 @@ use std::io::Read;
use std::{env, process, fs, fmt};

use docopt::Docopt;
use ethstore::dir::{paths, KeyDirectory, RootDiskDirectory};
use ethstore::accounts_dir::{KeyDirectory, RootDiskDirectory};
use ethstore::ethkey::Address;
use ethstore::{EthStore, SimpleSecretStore, SecretStore, import_accounts, PresaleWallet, SecretVaultRef, StoreAccountRef};

Expand Down Expand Up @@ -157,11 +158,11 @@ fn main() {

fn key_dir(location: &str) -> Result<Box<KeyDirectory>, Error> {
let dir: Box<KeyDirectory> = match location {
"geth" => Box::new(RootDiskDirectory::create(paths::geth(false))?),
"geth-test" => Box::new(RootDiskDirectory::create(paths::geth(true))?),
"geth" => Box::new(RootDiskDirectory::create(dir::geth(false))?),
"geth-test" => Box::new(RootDiskDirectory::create(dir::geth(true))?),
path if path.starts_with("parity") => {
let chain = path.split('-').nth(1).unwrap_or("ethereum");
let path = paths::parity(chain);
let path = dir::parity(chain);
Box::new(RootDiskDirectory::create(path)?)
},
path => Box::new(RootDiskDirectory::create(path)?),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ mod test {
extern crate tempdir;

use std::{env, fs};
use super::RootDiskDirectory;
use dir::{KeyDirectory, VaultKey};
use super::{KeyDirectory, RootDiskDirectory, VaultKey};
use account::SafeAccount;
use ethkey::{Random, Generator};
use self::tempdir::TempDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use {SafeAccount, Error};
mod disk;
mod memory;
mod vault;
pub mod paths;

/// `VaultKeyDirectory::set_key` error
#[derive(Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ mod test {
use std::fs;
use std::io::Write;
use std::path::PathBuf;
use dir::VaultKey;
use super::VaultKey;
use super::{VAULT_FILE_NAME, check_vault_name, make_vault_dir_path, create_vault_file, read_vault_file, VaultDiskDirectory};
use self::tempdir::TempDir;

Expand Down
96 changes: 0 additions & 96 deletions ethstore/src/dir/paths.rs

This file was deleted.

4 changes: 2 additions & 2 deletions ethstore/src/ethstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::time::{Instant, Duration};
use crypto::KEY_ITERATIONS;
use random::Random;
use ethkey::{self, Signature, Address, Message, Secret, Public, KeyPair, ExtendedKeyPair};
use dir::{KeyDirectory, VaultKeyDirectory, VaultKey, SetKeyError};
use accounts_dir::{KeyDirectory, VaultKeyDirectory, VaultKey, SetKeyError};
use account::SafeAccount;
use presale::PresaleWallet;
use json::{self, Uuid, OpaqueKeyFile};
Expand Down Expand Up @@ -684,7 +684,7 @@ impl SimpleSecretStore for EthMultiStore {
mod tests {
extern crate tempdir;

use dir::{KeyDirectory, MemoryDirectory, RootDiskDirectory};
use accounts_dir::{KeyDirectory, MemoryDirectory, RootDiskDirectory};
use ethkey::{Random, Generator, KeyPair};
use secret_store::{SimpleSecretStore, SecretStore, SecretVaultRef, StoreAccountRef, Derivation};
use super::{EthStore, EthMultiStore};
Expand Down
7 changes: 4 additions & 3 deletions ethstore/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use std::path::Path;
use std::fs;

use ethkey::Address;
use dir::{paths, KeyDirectory, RootDiskDirectory, DiskKeyFileManager, KeyFileManager};
use accounts_dir::{KeyDirectory, RootDiskDirectory, DiskKeyFileManager, KeyFileManager};
use dir;
use Error;

/// Import an account from a file.
Expand Down Expand Up @@ -54,15 +55,15 @@ pub fn import_accounts(src: &KeyDirectory, dst: &KeyDirectory) -> Result<Vec<Add

/// Provide a `HashSet` of all accounts available for import from the Geth keystore.
pub fn read_geth_accounts(testnet: bool) -> Vec<Address> {
RootDiskDirectory::at(paths::geth(testnet))
RootDiskDirectory::at(dir::geth(testnet))
.load()
.map(|d| d.into_iter().map(|a| a.address).collect())
.unwrap_or_else(|_| Vec::new())
}

/// Import specific `desired` accounts from the Geth keystore into `dst`.
pub fn import_geth_accounts(dst: &KeyDirectory, desired: HashSet<Address>, testnet: bool) -> Result<Vec<Address>, Error> {
let src = RootDiskDirectory::at(paths::geth(testnet));
let src = RootDiskDirectory::at(dir::geth(testnet));
let accounts = src.load()?;
let existing_accounts = dst.load()?.into_iter().map(|a| a.address).collect::<HashSet<_>>();

Expand Down
3 changes: 2 additions & 1 deletion ethstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![warn(missing_docs)]

extern crate crypto as rcrypto;
extern crate dir;
extern crate itertools;
extern crate libc;
extern crate parking_lot;
Expand All @@ -41,7 +42,7 @@ extern crate log;
#[macro_use]
extern crate serde_derive;

pub mod dir;
pub mod accounts_dir;
pub mod ethkey;

mod account;
Expand Down
2 changes: 1 addition & 1 deletion ethstore/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod util;

use ethstore::{EthStore, SimpleSecretStore, SecretVaultRef, StoreAccountRef};
use ethstore::ethkey::{Random, Generator, Secret, KeyPair, verify_address};
use ethstore::dir::RootDiskDirectory;
use ethstore::accounts_dir::RootDiskDirectory;
use util::TransientDir;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ethstore/tests/util/transient_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::path::PathBuf;
use std::{env, fs};
use rand::{Rng, OsRng};
use ethstore::dir::{KeyDirectory, RootDiskDirectory};
use ethstore::accounts_dir::{KeyDirectory, RootDiskDirectory};
use ethstore::{Error, SafeAccount};

pub fn random_dir() -> PathBuf {
Expand Down
2 changes: 1 addition & 1 deletion parity/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::path::PathBuf;
use ethcore::ethstore::{EthStore, SecretStore, import_account, import_accounts, read_geth_accounts};
use ethcore::ethstore::dir::RootDiskDirectory;
use ethcore::ethstore::accounts_dir::RootDiskDirectory;
use ethcore::ethstore::SecretVaultRef;
use ethcore::account_provider::{AccountProvider, AccountProviderSettings};
use helpers::{password_prompt, password_from_file};
Expand Down
2 changes: 1 addition & 1 deletion parity/cli/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ macro_rules! usage {
use std::io::{Read, Write};
use parity_version::version;
use clap::{Arg, App, SubCommand, AppSettings, ArgMatches as ClapArgMatches, Error as ClapError, ErrorKind as ClapErrorKind};
use helpers::replace_home;
use dir::helpers::replace_home;
use std::ffi::OsStr;
use std::collections::HashMap;

Expand Down
7 changes: 4 additions & 3 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ use rpc::{IpcConfiguration, HttpConfiguration, WsConfiguration, UiConfiguration}
use rpc_apis::ApiSet;
use parity_rpc::NetworkSettings;
use cache::CacheConfig;
use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, replace_home, replace_home_and_local,
geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address, to_gas_limit, to_queue_strategy};
use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, geth_ipc_path, parity_ipc_path,
to_bootnodes, to_addresses, to_address, to_gas_limit, to_queue_strategy};
use dir::helpers::{replace_home, replace_home_and_local};
use params::{ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras, SpecType};
use ethcore_logger::Config as LogConfig;
use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path};
Expand Down Expand Up @@ -1866,7 +1867,7 @@ mod tests {

let base_path = ::dir::default_data_path();
let local_path = ::dir::default_local_path();
assert_eq!(std.directories().cache, ::helpers::replace_home_and_local(&base_path, &local_path, ::dir::CACHE_PATH));
assert_eq!(std.directories().cache, dir::helpers::replace_home_and_local(&base_path, &local_path, ::dir::CACHE_PATH));
assert_eq!(base.directories().cache, "/test/cache");
}
}
2 changes: 1 addition & 1 deletion parity/dapps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ use std::path::PathBuf;
use std::sync::Arc;

use dir::default_data_path;
use dir::helpers::replace_home;
use ethcore::client::{Client, BlockChainClient, BlockId};
use ethcore::transaction::{Transaction, Action};
use ethsync::LightSync;
use futures::{future, IntoFuture, Future};
use hash_fetch::fetch::Client as FetchClient;
use hash_fetch::urlhint::ContractClient;
use helpers::replace_home;
use light::client::LightChainClient;
use light::on_demand::{self, OnDemand};
use node_health::{SyncStatus, NodeHealth};
Expand Down
Loading