Merge branch 'master' into kill_unwraps

This commit is contained in:
Gav Wood
2016-07-08 17:31:30 +02:00
19 changed files with 283 additions and 69 deletions

View File

@@ -425,11 +425,11 @@ impl Configuration {
fn geth_ipc_path(&self) -> String {
if cfg!(windows) {
r"\\.\pipe\geth.ipc".to_owned()
}
else {
if self.args.flag_testnet { path::ethereum::with_testnet("geth.ipc") }
else { path::ethereum::with_default("geth.ipc") }
.to_str().unwrap().to_owned()
} else {
match self.args.flag_testnet {
true => path::ethereum::with_testnet("geth.ipc"),
false => path::ethereum::with_default("geth.ipc"),
}.to_str().unwrap().to_owned()
}
}

View File

@@ -22,7 +22,7 @@ use std::time::{Instant, Duration};
use std::sync::RwLock;
use std::ops::{Deref, DerefMut};
use ethsync::{EthSync, SyncProvider};
use util::{Uint, RwLockable};
use util::{Uint, RwLockable, NetworkService};
use ethcore::client::*;
use number_prefix::{binary_prefix, Standalone, Prefixed};
@@ -76,7 +76,7 @@ impl Informant {
}
#[cfg_attr(feature="dev", allow(match_bool))]
pub fn tick(&self, client: &Client, maybe_sync: Option<&EthSync>) {
pub fn tick<Message>(&self, client: &Client, maybe_sync: Option<(&EthSync, &NetworkService<Message>)>) where Message: Send + Sync + Clone + 'static {
let elapsed = self.last_tick.unwrapped_read().elapsed();
if elapsed < Duration::from_secs(5) {
return;
@@ -110,11 +110,13 @@ impl Informant {
paint(Yellow.bold(), format!("{:3}", ((report.gas_processed - last_report.gas_processed) / From::from(elapsed.as_milliseconds() * 1000)).low_u64())),
match maybe_sync {
Some(sync) => {
Some((sync, net)) => {
let sync_info = sync.status();
format!("{}/{} peers {} ",
let net_config = net.config();
format!("{}/{}/{} peers {} ",
paint(Green.bold(), format!("{:2}", sync_info.num_active_peers)),
paint(Green.bold(), format!("{:2}", sync_info.num_peers)),
paint(Green.bold(), format!("{:2}", net_config.ideal_peers)),
paint(Cyan.bold(), format!("{:>8}", format!("#{}", sync_info.last_imported_block_number.unwrap_or(chain_info.best_block_number)))),
)
}
@@ -128,7 +130,7 @@ impl Informant {
paint(Purple.bold(), format!("{:>8}", Informant::format_bytes(cache_info.total()))),
paint(Purple.bold(), format!("{:>8}", Informant::format_bytes(queue_info.mem_used))),
match maybe_sync {
Some(sync) => {
Some((sync, _)) => {
let sync_info = sync.status();
format!(" {} sync", paint(Purple.bold(), format!("{:>8}", Informant::format_bytes(sync_info.mem_used))))
}

View File

@@ -40,7 +40,9 @@ impl IoHandler<NetSyncMessage> for ClientIoHandler {
fn timeout(&self, _io: &IoContext<NetSyncMessage>, timer: TimerToken) {
if let INFO_TIMER = timer {
self.info.tick(&self.client, Some(&self.sync));
if let Some(net) = self.network.upgrade() {
self.info.tick(&self.client, Some((&self.sync, &net)));
}
}
}

View File

@@ -485,7 +485,7 @@ fn execute_import(conf: Configuration) {
Err(BlockImportError::Import(ImportError::AlreadyInChain)) => { trace!("Skipping block already in chain."); }
Err(e) => die!("Cannot import block: {:?}", e)
}
informant.tick(client.deref(), None);
informant.tick::<&'static ()>(client.deref(), None);
};
match format {