diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index d4fdb66c4..c5aa987f6 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -417,7 +417,7 @@ impl Client { /// New chain head event. pub fn new_chain_head(&self) { let h = self.chain.read().unwrap().best_block_hash(); - info!("New best block: #{}: {}", self.chain.read().unwrap().best_block_number(), h); + debug!("New best block: #{}: {}", self.chain.read().unwrap().best_block_number(), h); let b = OpenBlock::new( self.engine.deref().deref(), self.state_db.lock().unwrap().clone(), @@ -427,7 +427,7 @@ impl Client { b"Parity".to_vec() ); let b = b.close(); - info!("Sealed: hash={}, diff={}, number={}", b.hash(), b.block().header().difficulty(), b.block().header().number()); + debug!("Sealing: hash={}, diff={}, number={}", b.hash(), b.block().header().difficulty(), b.block().header().number()); *self.sealing_block.lock().unwrap() = Some(b); } diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index b26f38440..f96d69ce7 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -15,12 +15,12 @@ // along with Parity. If not, see . //! Eth rpc implementation. -use std::sync::{Arc, Weak}; use ethsync::{EthSync, SyncState}; use jsonrpc_core::*; use util::hash::*; use util::uint::*; use util::sha3::*; +use util::standard::{RwLock, HashMap, Arc, Weak}; use util::rlp::encode; use ethcore::client::*; use ethcore::block::{IsBlock}; @@ -34,7 +34,8 @@ use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncIn /// Eth rpc implementation. pub struct EthClient { client: Weak, - sync: Weak + sync: Weak, + hashrates: RwLock>, } impl EthClient { @@ -42,7 +43,8 @@ impl EthClient { pub fn new(client: &Arc, sync: &Arc) -> Self { EthClient { client: Arc::downgrade(client), - sync: Arc::downgrade(sync) + sync: Arc::downgrade(sync), + hashrates: RwLock::new(HashMap::new()), } } @@ -137,7 +139,7 @@ impl Eth for EthClient { // TODO: return real hashrate once we have mining fn hashrate(&self, params: Params) -> Result { match params { - Params::None => to_value(&U256::zero()), + Params::None => to_value(&self.hashrates.read().unwrap().iter().fold(0u64, |sum, (_, v)| sum + v)), _ => Err(Error::invalid_params()) } } @@ -215,7 +217,6 @@ impl Eth for EthClient { } fn work(&self, params: Params) -> Result { - println!("Work wanted: {:?}", params); match params { Params::None => { let c = take_weak!(self.client); @@ -235,6 +236,7 @@ impl Eth for EthClient { } fn submit_work(&self, params: Params) -> Result { + // TODO: println! should be debug! println!("Work submission: {:?}", params); from_params::<(H64, H256, H256)>(params).and_then(|(nonce, pow_hash, mix_hash)| { let c = take_weak!(self.client); @@ -244,9 +246,9 @@ impl Eth for EthClient { } fn submit_hashrate(&self, params: Params) -> Result { - println!("Hashrate submission: {:?}", params); + // TODO: Index should be U256. from_params::<(Index, H256)>(params).and_then(|(rate, id)| { - println!("Miner {} reports a hash rate of {} H/s", id, rate.value()); + self.hashrates.write().unwrap().insert(id, rate.value() as u64); to_value(&true) }) }