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

Import command summary #2102

Merged
merged 2 commits into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 17 additions & 5 deletions parity/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
use std::str::{FromStr, from_utf8};
use std::{io, fs};
use std::io::{BufReader, BufRead};
use std::time::Duration;
use std::time::{Instant, Duration};
use std::thread::sleep;
use std::sync::Arc;
use rustc_serialize::hex::FromHex;
use ethcore_logger::{setup_log, Config as LogConfig};
use io::{PanicHandler, ForwardPanic};
use util::ToPretty;
use util::{ToPretty, Uint};
use rlp::PayloadInfo;
use ethcore::service::ClientService;
use ethcore::client::{Mode, DatabaseCompactionProfile, Switch, VMType, BlockImportError, BlockChainClient, BlockID};
use ethcore::error::ImportError;
use ethcore::miner::Miner;
use cache::CacheConfig;
use informant::Informant;
use informant::{Informant, MillisecondDuration};
use io_handler::ImportIoHandler;
use params::{SpecType, Pruning};
use helpers::{to_client_config, execute_upgrades};
Expand Down Expand Up @@ -108,6 +108,8 @@ pub fn execute(cmd: BlockchainCmd) -> Result<String, String> {
}

fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
let timer = Instant::now();

// Setup panic handler
let panic_handler = PanicHandler::new_in_arc();

Expand Down Expand Up @@ -218,8 +220,18 @@ fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
}
}
client.flush_queue();

Ok("Import completed.".into())
let report = client.report();

let ms = timer.elapsed().as_milliseconds();
Ok(format!("Import completed in {} seconds, {} blocks, {} blk/s, {} transactions, {} tx/s, {} Mgas, {} Mgas/s",
ms / 1000,
report.blocks_imported,
(report.blocks_imported * 1000) as u64 / ms,
report.transactions_applied,
(report.transactions_applied * 1000) as u64 / ms,
report.gas_processed / From::from(1_000_000),
(report.gas_processed / From::from(ms * 1000)).low_u64(),
).into())
}

fn execute_export(cmd: ExportBlockchain) -> Result<String, String> {
Expand Down
2 changes: 1 addition & 1 deletion parity/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct Informant {
skipped: AtomicUsize,
}

trait MillisecondDuration {
pub trait MillisecondDuration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and the as_milliseconds function are missing docs.

fn as_milliseconds(&self) -> u64;
}

Expand Down