Merge pull request #1764 from ethcore/log-tweak

Log tweak
This commit is contained in:
Tomasz Drwięga 2016-07-29 12:39:19 +02:00 committed by GitHub
commit 5d4925d582
5 changed files with 31 additions and 11 deletions

View File

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

View File

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

View File

@ -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::<Vec<_>>();
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());
}
}

View File

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

View File

@ -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<AccountProvider, String> {
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<A
let from = GethDirectory::open(t);
let to = DiskDirectory::create(dirs.keys.clone()).unwrap();
if let Err(err) = import_accounts(&from, &to) {
warn!("Import geth accounts failed. {}", err);
match import_accounts(&from, &to) {
Ok(_) => {}
Err(Error::Io(ref io_err)) if io_err.kind() == ErrorKind::NotFound => {}
Err(err) => warn!("Import geth accounts failed. {}", err)
}
}