diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 8b120caa2..30bd7a5b1 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -570,9 +570,9 @@ impl BlockChain { if let BlockLocation::BranchBecomingCanonChain(ref d) = info.location { info!(target: "reorg", "Reorg to {} ({} {} {})", Colour::Yellow.bold().paint(format!("#{} {}", info.number, info.hash)), - Colour::Red.paint(d.retracted.iter().fold(String::new(), |acc, h| format!("{} {}", acc, h))), - Colour::White.paint(format!("#{} {}", d.ancestor, self.block_details(&d.ancestor).expect("`ancestor` is in the route; qed").number)), - Colour::Green.paint(d.enacted.iter().fold(String::new(), |acc, h| format!("{} {}", acc, h))) + Colour::Red.paint(d.retracted.iter().join(" ")), + Colour::White.paint(format!("#{} {}", self.block_details(&d.ancestor).expect("`ancestor` is in the route; qed").number, d.ancestor)), + Colour::Green.paint(d.enacted.iter().join(" ")) ); } diff --git a/parity/cli.rs b/parity/cli.rs index 11d58eb22..eeab2563a 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -48,8 +48,8 @@ Operating Options: [default: 3600]. --chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file or olympic, frontier, - homestead, mainnet, morden, homestead-dogmatic, or - testnet [default: homestead]. + homestead, mainnet, morden, classic or testnet + [default: homestead]. -d --db-path PATH Specify the database & configuration directory path [default: $HOME/.parity]. --keys-path PATH Specify the path for JSON key files to be found diff --git a/parity/configuration.rs b/parity/configuration.rs index 29301dfd3..9e779ef91 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -350,11 +350,11 @@ impl Configuration { let mut buffer = String::new(); let mut node_file = try!(File::open(path).map_err(|e| format!("Error opening reserved nodes file: {}", e))); try!(node_file.read_to_string(&mut buffer).map_err(|_| "Error reading reserved node file")); - if let Some(invalid) = buffer.lines().find(|s| !is_valid_node_url(s)) { - Err(format!("Invalid node address format given for a boot node: {}", invalid)) - } else { - Ok(buffer.lines().map(|s| s.to_owned()).collect()) + let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| s.len() > 0).collect::>(); + if let Some(invalid) = lines.iter().find(|s| !is_valid_node_url(s)) { + return Err(format!("Invalid node address format given for a boot node: {}", invalid)); } + Ok(lines) }, None => Ok(Vec::new()) } @@ -538,6 +538,9 @@ mod tests { use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain}; use presale::ImportWallet; use account::{AccountCmd, NewAccount, ImportAccounts}; + use devtools::{RandomTempPath}; + use std::io::Write; + use std::fs::{File, create_dir}; #[derive(Debug, PartialEq)] struct TestPasswordReader(&'static str); @@ -769,5 +772,16 @@ mod tests { // then assert_eq!(conf0.signer_enabled(), false); } + + #[test] + fn should_not_bail_on_empty_line_in_reserved_peers() { + let temp = RandomTempPath::new(); + create_dir(temp.as_str().to_owned()).unwrap(); + let filename = temp.as_str().to_owned() + "/peers"; + File::create(filename.clone()).unwrap().write_all(b" \n\t\n").unwrap(); + let args = vec!["parity", "--reserved-peers", &filename]; + let conf = Configuration::parse(args).unwrap(); + assert!(conf.init_reserved_nodes().is_ok()); + } } diff --git a/parity/main.rs b/parity/main.rs index 4c1aae65e..ca578c787 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -25,6 +25,8 @@ extern crate docopt; extern crate num_cpus; extern crate rustc_serialize; +extern crate ethcore_devtools as devtools; +#[macro_use] extern crate ethcore_util as util; extern crate ethcore; extern crate ethsync; diff --git a/parity/run.rs b/parity/run.rs index 53356b414..03690e8f9 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -16,6 +16,7 @@ use std::sync::{Arc, Mutex, Condvar}; use std::path::Path; +use std::io::ErrorKind; use ctrlc::CtrlC; use fdlimit::raise_fd_limit; use ethcore_logger::{Config as LogConfig, setup_log}; @@ -283,6 +284,7 @@ fn daemonize(_pid_file: String) -> Result<(), String> { fn prepare_account_provider(dirs: &Directories, cfg: AccountsConfig) -> Result { use ethcore::ethstore::{import_accounts, EthStore}; use ethcore::ethstore::dir::{GethDirectory, DirectoryType, DiskDirectory}; + use ethcore::ethstore::Error; let passwords = try!(passwords_from_files(cfg.password_files)); @@ -295,8 +297,10 @@ fn prepare_account_provider(dirs: &Directories, cfg: AccountsConfig) -> Result {} + Err(Error::Io(ref io_err)) if io_err.kind() == ErrorKind::NotFound => {} + Err(err) => warn!("Import geth accounts failed. {}", err) } }