From f31ddec3a88a9f7464cb36348d4eab9bceffef83 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 29 Jun 2016 21:28:21 +0300 Subject: [PATCH] block queue info --- ethcore/src/block_queue.rs | 18 ++---------- ethcore/src/blockchain/block_info.rs | 40 -------------------------- ethcore/src/client/client.rs.in | 30 ++++++++++++++++--- ethcore/src/miner/transaction_queue.rs | 1 + ethcore/src/types/block_queue_info.rs | 32 +++++++++++++++++++++ ethcore/src/types/mod.rs.in | 1 + 6 files changed, 62 insertions(+), 60 deletions(-) create mode 100644 ethcore/src/types/block_queue_info.rs diff --git a/ethcore/src/block_queue.rs b/ethcore/src/block_queue.rs index ce99dcccd..2288c1509 100644 --- a/ethcore/src/block_queue.rs +++ b/ethcore/src/block_queue.rs @@ -28,6 +28,8 @@ use service::*; use client::BlockStatus; use util::panics::*; +pub use types::block_queue_info::BlockQueueInfo; + known_heap_size!(0, UnverifiedBlock, VerifyingBlock, PreverifiedBlock); const MIN_MEM_LIMIT: usize = 16384; @@ -53,22 +55,6 @@ impl Default for BlockQueueConfig { } } -/// Block queue status -#[derive(Debug)] -pub struct BlockQueueInfo { - /// Number of queued blocks pending verification - pub unverified_queue_size: usize, - /// Number of verified queued blocks pending import - pub verified_queue_size: usize, - /// Number of blocks being verified - pub verifying_queue_size: usize, - /// Configured maximum number of blocks in the queue - pub max_queue_size: usize, - /// Configured maximum number of bytes to use - pub max_mem_use: usize, - /// Heap memory used in bytes - pub mem_used: usize, -} impl BlockQueueInfo { /// The total size of the queues. diff --git a/ethcore/src/blockchain/block_info.rs b/ethcore/src/blockchain/block_info.rs index eb3677c25..52fd32291 100644 --- a/ethcore/src/blockchain/block_info.rs +++ b/ethcore/src/blockchain/block_info.rs @@ -54,43 +54,3 @@ pub struct BranchBecomingCanonChainData { /// Hashes of the blocks which were invalidated. pub retracted: Vec, } - -impl FromRawBytesVariable for BranchBecomingCanonChainData { - fn from_bytes_variable(bytes: &[u8]) -> Result { - type Tuple = (Vec, Vec, H256); - let (enacted, retracted, ancestor) = try!(Tuple::from_bytes_variable(bytes)); - Ok(BranchBecomingCanonChainData { ancestor: ancestor, enacted: enacted, retracted: retracted }) - } -} - -impl FromRawBytesVariable for BlockLocation { - fn from_bytes_variable(bytes: &[u8]) -> Result { - match bytes[0] { - 0 => Ok(BlockLocation::CanonChain), - 1 => Ok(BlockLocation::Branch), - 2 => Ok(BlockLocation::BranchBecomingCanonChain( - try!(BranchBecomingCanonChainData::from_bytes_variable(&bytes[1..bytes.len()])))), - _ => Err(FromBytesError::UnknownMarker) - } - } -} - -impl ToBytesWithMap for BranchBecomingCanonChainData { - fn to_bytes_map(&self) -> Vec { - (&self.enacted, &self.retracted, &self.ancestor).to_bytes_map() - } -} - -impl ToBytesWithMap for BlockLocation { - fn to_bytes_map(&self) -> Vec { - match *self { - BlockLocation::CanonChain => vec![0u8], - BlockLocation::Branch => vec![1u8], - BlockLocation::BranchBecomingCanonChain(ref data) => { - let mut bytes = (&data.enacted, &data.retracted, &data.ancestor).to_bytes_map(); - bytes.insert(0, 2u8); - bytes - } - } - } -} diff --git a/ethcore/src/client/client.rs.in b/ethcore/src/client/client.rs.in index 0c77574a9..1dc6512ab 100644 --- a/ethcore/src/client/client.rs.in +++ b/ethcore/src/client/client.rs.in @@ -14,10 +14,32 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::marker::PhantomData; +use std::path::PathBuf; +use std::collections::{HashSet, HashMap}; +use std::ops::Deref; +use std::mem; +use std::collections::VecDeque; +use std::sync::*; +use std::path::Path; +use std::fmt; +use util::Itertools; + +// util +use util::numbers::*; +use util::panics::*; +use util::network::*; +use util::io::*; +use util::rlp; +use util::sha3::*; +use util::{UtilError, CryptoError, Bytes, Signature, Secret, ec}; +use util::rlp::{encode, decode, RlpStream, Rlp}; +use util::journaldb; +use util::journaldb::JournalDB; use std::path::PathBuf; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; -use util::*; -use util::panics::*; + +// other use views::BlockView; use error::{Error, ImportError, ExecutionError, BlockError, ImportResult}; use header::{BlockNumber, Header}; @@ -478,7 +500,7 @@ impl Client { } } -//#[derive(Ipc)] +#[derive(Ipc)] impl BlockChainClient for Client { fn call(&self, t: &SignedTransaction, analytics: CallAnalytics) -> Result { let header = self.block_header(BlockID::Latest).unwrap(); @@ -770,7 +792,7 @@ impl BlockChainClient for Client { self.build_last_hashes(self.chain.best_block_hash()) } - fn import_transactions(&self, transactions: Vec) -> Vec> { + fn import_transactions(&self, transactions: Vec) -> Vec> { let fetch_account = |a: &Address| AccountDetails { nonce: self.latest_nonce(a), balance: self.latest_balance(a), diff --git a/ethcore/src/miner/transaction_queue.rs b/ethcore/src/miner/transaction_queue.rs index 7f5b59c38..b6c8d4edf 100644 --- a/ethcore/src/miner/transaction_queue.rs +++ b/ethcore/src/miner/transaction_queue.rs @@ -197,6 +197,7 @@ struct VerifiedTransaction { /// transaction origin origin: TransactionOrigin, } + impl VerifiedTransaction { fn new(transaction: SignedTransaction, origin: TransactionOrigin) -> Result { try!(transaction.sender()); diff --git a/ethcore/src/types/block_queue_info.rs b/ethcore/src/types/block_queue_info.rs new file mode 100644 index 000000000..d6fd8a9cc --- /dev/null +++ b/ethcore/src/types/block_queue_info.rs @@ -0,0 +1,32 @@ +// 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 . + +/// Block queue status +#[derive(Debug, Binary)] +pub struct BlockQueueInfo { + /// Number of queued blocks pending verification + pub unverified_queue_size: usize, + /// Number of verified queued blocks pending import + pub verified_queue_size: usize, + /// Number of blocks being verified + pub verifying_queue_size: usize, + /// Configured maximum number of blocks in the queue + pub max_queue_size: usize, + /// Configured maximum number of bytes to use + pub max_mem_use: usize, + /// Heap memory used in bytes + pub mem_used: usize, +} diff --git a/ethcore/src/types/mod.rs.in b/ethcore/src/types/mod.rs.in index b51e9e57b..a60ee0f08 100644 --- a/ethcore/src/types/mod.rs.in +++ b/ethcore/src/types/mod.rs.in @@ -25,3 +25,4 @@ pub mod executed; pub mod block_status; pub mod account_diff; pub mod state_diff; +pub mod block_queue_info;