Merge branch 'master' into sync-svc
This commit is contained in:
@@ -47,18 +47,13 @@ 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, or testnet
|
||||
[default: homestead].
|
||||
homestead, mainnet, morden, homestead-dogmatic, 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
|
||||
[default: $HOME/.parity/keys].
|
||||
--identity NAME Specify your node's name.
|
||||
--fork POLICY Specifies the client's fork policy. POLICY must be
|
||||
one of:
|
||||
dogmatic - sticks rigidly to the standard chain.
|
||||
none - goes with whatever fork is decided but
|
||||
votes for none. [default: none].
|
||||
|
||||
Account Options:
|
||||
--unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution.
|
||||
@@ -145,7 +140,7 @@ Sealing/Mining Options:
|
||||
none - never reseal on new transactions;
|
||||
own - reseal only on a new local transaction;
|
||||
ext - reseal only on a new external transaction;
|
||||
all - reseal on all new transactions [default: all].
|
||||
all - reseal on all new transactions [default: own].
|
||||
--reseal-min-period MS Specify the minimum time between reseals from
|
||||
incoming transactions. MS is time measured in
|
||||
milliseconds [default: 2000].
|
||||
@@ -292,7 +287,6 @@ pub struct Args {
|
||||
pub flag_chain: String,
|
||||
pub flag_db_path: String,
|
||||
pub flag_identity: String,
|
||||
pub flag_fork: String,
|
||||
pub flag_unlock: Option<String>,
|
||||
pub flag_password: Vec<String>,
|
||||
pub flag_cache: Option<usize>,
|
||||
|
||||
@@ -46,12 +46,6 @@ pub struct Directories {
|
||||
pub signer: String,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Debug)]
|
||||
pub enum Policy {
|
||||
None,
|
||||
Dogmatic,
|
||||
}
|
||||
|
||||
impl Configuration {
|
||||
pub fn parse() -> Self {
|
||||
Configuration {
|
||||
@@ -131,14 +125,6 @@ impl Configuration {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn policy(&self) -> Policy {
|
||||
match self.args.flag_fork.as_str() {
|
||||
"none" => Policy::None,
|
||||
"dogmatic" => Policy::Dogmatic,
|
||||
x => die!("{}: Invalid value given for --policy option. Use --help for more info.", x)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gas_floor_target(&self) -> U256 {
|
||||
let d = &self.args.flag_gas_floor_target;
|
||||
U256::from_dec_str(d).unwrap_or_else(|_| {
|
||||
@@ -195,7 +181,7 @@ impl Configuration {
|
||||
let wei_per_usd: f32 = 1.0e18 / usd_per_eth;
|
||||
let gas_per_tx: f32 = 21000.0;
|
||||
let wei_per_gas: f32 = wei_per_usd * usd_per_tx / gas_per_tx;
|
||||
info!("Using a fixed conversion rate of Ξ1 = {} ({} wei/gas)", format!("US${}", usd_per_eth).apply(White.bold()), format!("{}", wei_per_gas).apply(Yellow.bold()));
|
||||
info!("Using a fixed conversion rate of Ξ1 = {} ({} wei/gas)", White.bold().paint(format!("US${}", usd_per_eth)), Yellow.bold().paint(format!("{}", wei_per_gas)));
|
||||
GasPricer::Fixed(U256::from_dec_str(&format!("{:.0}", wei_per_gas)).unwrap())
|
||||
}
|
||||
}
|
||||
@@ -214,6 +200,7 @@ impl Configuration {
|
||||
pub fn spec(&self) -> Spec {
|
||||
match self.chain().as_str() {
|
||||
"frontier" | "homestead" | "mainnet" => ethereum::new_frontier(),
|
||||
"homestead-dogmatic" => ethereum::new_frontier_dogmatic(),
|
||||
"morden" | "testnet" => ethereum::new_morden(),
|
||||
"olympic" => ethereum::new_olympic(),
|
||||
f => Spec::load(contents(f).unwrap_or_else(|_| {
|
||||
|
||||
@@ -20,6 +20,7 @@ use self::ansi_term::Style;
|
||||
|
||||
use std::time::{Instant, Duration};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use isatty::{stdout_isatty};
|
||||
use ethsync::{SyncStatus, NetworkConfiguration};
|
||||
use util::{Uint, RwLock};
|
||||
use ethcore::client::*;
|
||||
@@ -91,7 +92,7 @@ impl Informant {
|
||||
let mut write_report = self.report.write();
|
||||
let report = client.report();
|
||||
|
||||
let paint = |c: Style, t: String| match self.with_color {
|
||||
let paint = |c: Style, t: String| match self.with_color && stdout_isatty() {
|
||||
true => format!("{}", c.paint(t)),
|
||||
false => t,
|
||||
};
|
||||
|
||||
@@ -53,6 +53,7 @@ extern crate ansi_term;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate regex;
|
||||
extern crate isatty;
|
||||
|
||||
#[cfg(feature = "dapps")]
|
||||
extern crate ethcore_dapps;
|
||||
@@ -83,7 +84,7 @@ use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
use rustc_serialize::hex::FromHex;
|
||||
use ctrlc::CtrlC;
|
||||
use util::{H256, ToPretty, PayloadInfo, Bytes, Colour, Applyable, version, journaldb};
|
||||
use util::{H256, ToPretty, PayloadInfo, Bytes, Colour, version, journaldb};
|
||||
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
|
||||
use ethcore::client::{BlockID, BlockChainClient, ClientConfig, get_db_path, BlockImportError, Mode};
|
||||
use ethcore::error::{ImportError};
|
||||
@@ -101,7 +102,7 @@ use rpc::RpcServer;
|
||||
use signer::{SignerServer, new_token};
|
||||
use dapps::WebappServer;
|
||||
use io_handler::ClientIoHandler;
|
||||
use configuration::{Policy, Configuration};
|
||||
use configuration::{Configuration};
|
||||
|
||||
fn main() {
|
||||
let conf = Configuration::parse();
|
||||
@@ -179,7 +180,7 @@ fn execute_upgrades(conf: &Configuration, spec: &Spec, client_config: &ClientCon
|
||||
let db_path = get_db_path(Path::new(&conf.path()), client_config.pruning, spec.genesis_header().hash());
|
||||
let result = migrate(&db_path, client_config.pruning);
|
||||
if let Err(err) = result {
|
||||
die_with_message(&format!("{}", err));
|
||||
die_with_message(&format!("{} DB path: {}", err, db_path.to_string_lossy()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,18 +193,18 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
// Raise fdlimit
|
||||
unsafe { ::fdlimit::raise_fd_limit(); }
|
||||
|
||||
info!("Starting {}", format!("{}", version()).apply(Colour::White.bold()));
|
||||
info!("Using state DB journalling strategy {}", match client_config.pruning {
|
||||
info!("Starting {}", Colour::White.bold().paint(format!("{}", version())));
|
||||
info!("Using state DB journalling strategy {}", Colour::White.bold().paint(match client_config.pruning {
|
||||
journaldb::Algorithm::Archive => "archive",
|
||||
journaldb::Algorithm::EarlyMerge => "light",
|
||||
journaldb::Algorithm::OverlayRecent => "fast",
|
||||
journaldb::Algorithm::RefCounted => "basic",
|
||||
}.apply(Colour::White.bold()));
|
||||
}));
|
||||
|
||||
// Display warning about using experimental journaldb types
|
||||
match client_config.pruning {
|
||||
journaldb::Algorithm::EarlyMerge | journaldb::Algorithm::RefCounted => {
|
||||
warn!("Your chosen strategy is {}! You can re-run with --pruning to change.", "unstable".apply(Colour::Red.bold()));
|
||||
warn!("Your chosen strategy is {}! You can re-run with --pruning to change.", Colour::Red.bold().paint("unstable"));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -214,11 +215,6 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
warn!("NOTE that Signer will not ask you to confirm transactions from unlocked account.");
|
||||
}
|
||||
|
||||
// Check fork settings.
|
||||
if conf.policy() != Policy::None {
|
||||
warn!("Value given for --policy, yet no proposed forks exist. Ignoring.");
|
||||
}
|
||||
|
||||
let net_settings = conf.net_settings(&spec);
|
||||
let sync_config = conf.sync_config(&spec);
|
||||
|
||||
|
||||
@@ -37,11 +37,15 @@ const VERSION_FILE_NAME: &'static str = "db_version";
|
||||
pub enum Error {
|
||||
/// Returned when current version cannot be read or guessed.
|
||||
UnknownDatabaseVersion,
|
||||
/// Returned when migration is not possible.
|
||||
/// Migration does not support existing pruning algorithm.
|
||||
UnsuportedPruningMethod,
|
||||
/// Existing DB is newer than the known one.
|
||||
FutureDBVersion,
|
||||
/// Migration is not possible.
|
||||
MigrationImpossible,
|
||||
/// Returned when migration unexpectadly failed.
|
||||
/// Migration unexpectadly failed.
|
||||
MigrationFailed,
|
||||
/// Returned when migration was completed succesfully,
|
||||
/// Migration was completed succesfully,
|
||||
/// but there was a problem with io.
|
||||
Io(IoError),
|
||||
}
|
||||
@@ -50,9 +54,11 @@ impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
|
||||
let out = match *self {
|
||||
Error::UnknownDatabaseVersion => "Current database version cannot be read".into(),
|
||||
Error::MigrationImpossible => format!("Migration to version {} is not possible", CURRENT_VERSION),
|
||||
Error::MigrationFailed => "Migration unexpectedly failed".into(),
|
||||
Error::Io(ref err) => format!("Unexpected io error: {}", err),
|
||||
Error::UnsuportedPruningMethod => "Unsupported pruning method for database migration. Delete DB and resync.".into(),
|
||||
Error::FutureDBVersion => "Database was created with newer client version. Upgrade your client or delete DB and resync.".into(),
|
||||
Error::MigrationImpossible => format!("Database migration to version {} is not possible.", CURRENT_VERSION),
|
||||
Error::MigrationFailed => "Database migration unexpectedly failed".into(),
|
||||
Error::Io(ref err) => format!("Unexpected io error on DB migration: {}.", err),
|
||||
};
|
||||
|
||||
write!(f, "{}", out)
|
||||
@@ -159,7 +165,7 @@ fn state_database_migrations(pruning: Algorithm) -> Result<MigrationManager, Err
|
||||
let res = match pruning {
|
||||
Algorithm::Archive => manager.add_migration(migrations::state::ArchiveV7::default()),
|
||||
Algorithm::OverlayRecent => manager.add_migration(migrations::state::OverlayRecentV7::default()),
|
||||
_ => die!("Unsupported pruning method for migration. Delete DB and resync"),
|
||||
_ => return Err(Error::UnsuportedPruningMethod),
|
||||
};
|
||||
|
||||
try!(res.map_err(|_| Error::MigrationImpossible));
|
||||
@@ -207,12 +213,14 @@ pub fn migrate(path: &Path, pruning: Algorithm) -> Result<(), Error> {
|
||||
|
||||
// migrate the databases.
|
||||
// main db directory may already exists, so let's check if we have blocks dir
|
||||
if version != CURRENT_VERSION && exists(&blocks_database_path(path)) {
|
||||
if version < CURRENT_VERSION && exists(&blocks_database_path(path)) {
|
||||
println!("Migrating database from version {} to {}", version, CURRENT_VERSION);
|
||||
try!(migrate_database(version, blocks_database_path(path), try!(blocks_database_migrations())));
|
||||
try!(migrate_database(version, extras_database_path(path), try!(extras_database_migrations())));
|
||||
try!(migrate_database(version, state_database_path(path), try!(state_database_migrations(pruning))));
|
||||
println!("Migration finished");
|
||||
} else if version > CURRENT_VERSION {
|
||||
return Err(Error::FutureDBVersion);
|
||||
}
|
||||
|
||||
// update version file.
|
||||
|
||||
@@ -19,11 +19,12 @@ use std::env;
|
||||
use std::sync::Arc;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use isatty::{stderr_isatty};
|
||||
use time;
|
||||
use env_logger::LogBuilder;
|
||||
use regex::Regex;
|
||||
use util::RotatingLogger;
|
||||
use util::log::{Applyable, Colour};
|
||||
use util::log::Colour;
|
||||
|
||||
/// Sets up the logger
|
||||
pub fn setup_log(init: &Option<String>, enable_color: bool, log_to_file: &Option<String>) -> Arc<RotatingLogger> {
|
||||
@@ -47,19 +48,26 @@ pub fn setup_log(init: &Option<String>, enable_color: bool, log_to_file: &Option
|
||||
builder.parse(s);
|
||||
}
|
||||
|
||||
let logs = Arc::new(RotatingLogger::new(levels, enable_color));
|
||||
let enable_color = enable_color && stderr_isatty();
|
||||
let logs = Arc::new(RotatingLogger::new(levels));
|
||||
let logger = logs.clone();
|
||||
let maybe_file = log_to_file.as_ref().map(|f| File::create(f).unwrap_or_else(|_| die!("Cannot write to log file given: {}", f)));
|
||||
let format = move |record: &LogRecord| {
|
||||
let timestamp = time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap();
|
||||
|
||||
let format = if max_log_level() <= LogLevelFilter::Info {
|
||||
format!("{}{}", timestamp.apply(Colour::Black.bold()), record.args())
|
||||
let with_color = if max_log_level() <= LogLevelFilter::Info {
|
||||
format!("{}{}", Colour::Black.bold().paint(timestamp), record.args())
|
||||
} else {
|
||||
format!("{}{}:{}: {}", timestamp.apply(Colour::Black.bold()), record.level(), record.target(), record.args())
|
||||
format!("{}{}:{}: {}", Colour::Black.bold().paint(timestamp), record.level(), record.target(), record.args())
|
||||
};
|
||||
|
||||
let removed_color = kill_color(with_color.as_ref());
|
||||
|
||||
let ret = match enable_color {
|
||||
true => with_color,
|
||||
false => removed_color.clone(),
|
||||
};
|
||||
|
||||
let removed_color = kill_color(format.as_ref());
|
||||
if let Some(mut file) = maybe_file.as_ref() {
|
||||
// ignore errors - there's nothing we can do
|
||||
let _ = file.write_all(removed_color.as_bytes());
|
||||
@@ -67,7 +75,7 @@ pub fn setup_log(init: &Option<String>, enable_color: bool, log_to_file: &Option
|
||||
}
|
||||
logger.append(removed_color);
|
||||
|
||||
format
|
||||
ret
|
||||
};
|
||||
builder.format(format);
|
||||
builder.init().unwrap();
|
||||
@@ -84,7 +92,7 @@ fn kill_color(s: &str) -> String {
|
||||
#[test]
|
||||
fn should_remove_colour() {
|
||||
let before = "test";
|
||||
let after = kill_color(&before.apply(Colour::Red.bold()));
|
||||
let after = kill_color(&Colour::Red.bold().paint(before));
|
||||
assert_eq!(after, "test");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ use std::path::PathBuf;
|
||||
use ansi_term::Colour;
|
||||
use util::panics::{ForwardPanic, PanicHandler};
|
||||
use util::path::restrict_permissions_owner;
|
||||
use util::Applyable;
|
||||
use rpc_apis;
|
||||
use ethcore_signer as signer;
|
||||
use die::*;
|
||||
@@ -60,7 +59,7 @@ pub fn new_token(path: String) -> io::Result<()> {
|
||||
let mut codes = try!(signer::AuthCodes::from_file(&path));
|
||||
let code = try!(codes.generate_new());
|
||||
try!(codes.to_file(&path));
|
||||
println!("This key code will authorise your System Signer UI: {}", code.apply(Colour::White.bold()));
|
||||
info!("This key code will authorise your System Signer UI: {}", Colour::White.bold().paint(code));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user