From beb33672bd03da604295203a14dfb2fb3536fd15 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 5 May 2016 23:47:07 +0400 Subject: [PATCH] blockchain info --- ethcore/src/client/client.rs | 16 +------------- ethcore/src/types/blockchain_info.rs | 33 ++++++++++++++++++++++++++++ ethcore/src/types/mod.rs | 1 + 3 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 ethcore/src/types/blockchain_info.rs diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 23b81b34e..e9aba8415 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -44,6 +44,7 @@ use receipt::LocalizedReceipt; pub use blockchain::CacheSize as BlockChainCacheSize; use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase}; use trace; +pub use types::blockchain_info::BlockChainInfo; /// General block status #[derive(Debug, Eq, PartialEq)] @@ -58,21 +59,6 @@ pub enum BlockStatus { Unknown, } -/// Information about the blockchain gathered together. -#[derive(Debug)] -pub struct BlockChainInfo { - /// Blockchain difficulty. - pub total_difficulty: U256, - /// Block queue difficulty. - pub pending_total_difficulty: U256, - /// Genesis block hash. - pub genesis_hash: H256, - /// Best blockchain block hash. - pub best_block_hash: H256, - /// Best blockchain block number. - pub best_block_number: BlockNumber -} - impl fmt::Display for BlockChainInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "#{}.{}", self.best_block_number, self.best_block_hash) diff --git a/ethcore/src/types/blockchain_info.rs b/ethcore/src/types/blockchain_info.rs new file mode 100644 index 000000000..aacf77baf --- /dev/null +++ b/ethcore/src/types/blockchain_info.rs @@ -0,0 +1,33 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +use util::*; +use header::BlockNumber; + +/// Information about the blockchain gathered together. +#[derive(Debug)] +pub struct BlockChainInfo { + /// Blockchain difficulty. + pub total_difficulty: U256, + /// Block queue difficulty. + pub pending_total_difficulty: U256, + /// Genesis block hash. + pub genesis_hash: H256, + /// Best blockchain block hash. + pub best_block_hash: H256, + /// Best blockchain block number. + pub best_block_number: BlockNumber +} diff --git a/ethcore/src/types/mod.rs b/ethcore/src/types/mod.rs index ad8853216..b7f9ee3ce 100644 --- a/ethcore/src/types/mod.rs +++ b/ethcore/src/types/mod.rs @@ -20,3 +20,4 @@ pub mod transaction; pub mod ids; pub mod receipt; pub mod tree_route; +pub mod blockchain_info;