Merge pull request #800 from ethcore/fixjsonrpc

Increase threads to num_cpus & fix author reporting
This commit is contained in:
Arkadiy Paronyan 2016-03-22 21:08:59 +01:00
commit ebd7273071
6 changed files with 21 additions and 4 deletions

1
Cargo.lock generated
View File

@ -15,6 +15,7 @@ dependencies = [
"ethsync 1.1.0", "ethsync 1.1.0",
"fdlimit 0.1.0", "fdlimit 0.1.0",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rpassword 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -18,6 +18,7 @@ time = "0.1"
ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" } ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" }
fdlimit = { path = "util/fdlimit" } fdlimit = { path = "util/fdlimit" }
daemonize = "0.2" daemonize = "0.2"
num_cpus = "0.2"
number_prefix = "0.2" number_prefix = "0.2"
rpassword = "0.1" rpassword = "0.1"
clippy = { version = "0.0.54", optional = true } clippy = { version = "0.0.54", optional = true }

View File

@ -65,7 +65,7 @@ pub use transaction_queue::{TransactionQueue, AccountDetails};
pub use miner::{Miner}; pub use miner::{Miner};
use std::sync::Mutex; use std::sync::Mutex;
use util::{H256, Address, Bytes}; use util::{H256, Address, FixedHash, Bytes};
use ethcore::client::{BlockChainClient}; use ethcore::client::{BlockChainClient};
use ethcore::block::{ClosedBlock}; use ethcore::block::{ClosedBlock};
use ethcore::error::{Error}; use ethcore::error::{Error};
@ -77,6 +77,12 @@ pub trait MinerService : Send + Sync {
/// Returns miner's status. /// Returns miner's status.
fn status(&self) -> MinerStatus; fn status(&self) -> MinerStatus;
/// Get the author that we will seal blocks as.
fn author(&self) -> Address { Address::zero() }
/// Get the extra_data that we will seal blocks wuth.
fn extra_data(&self) -> Bytes { vec![] }
/// Imports transactions to transaction queue. /// Imports transactions to transaction queue.
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>> fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>>
where T: Fn(&Address) -> AccountDetails; where T: Fn(&Address) -> AccountDetails;

View File

@ -146,6 +146,14 @@ impl MinerService for Miner {
} }
} }
fn author(&self) -> Address {
*self.author.read().unwrap()
}
fn extra_data(&self) -> Bytes {
self.extra_data.read().unwrap().clone()
}
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>> fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>>
where T: Fn(&Address) -> AccountDetails { where T: Fn(&Address) -> AccountDetails {
let mut transaction_queue = self.transaction_queue.lock().unwrap(); let mut transaction_queue = self.transaction_queue.lock().unwrap();

View File

@ -20,6 +20,7 @@
#![cfg_attr(feature="dev", feature(plugin))] #![cfg_attr(feature="dev", feature(plugin))]
#![cfg_attr(feature="dev", plugin(clippy))] #![cfg_attr(feature="dev", plugin(clippy))]
extern crate docopt; extern crate docopt;
extern crate num_cpus;
extern crate rustc_serialize; extern crate rustc_serialize;
extern crate ethcore_util as util; extern crate ethcore_util as util;
extern crate ethcore; extern crate ethcore;
@ -269,7 +270,7 @@ fn setup_rpc_server(
} }
} }
} }
Some(server.start_http(url, cors_domain, 1)) Some(server.start_http(url, cors_domain, ::num_cpus::get()))
} }
#[cfg(not(feature = "rpc"))] #[cfg(not(feature = "rpc"))]

View File

@ -232,8 +232,8 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
// TODO: do not hardcode author. // TODO: do not hardcode author.
fn author(&self, params: Params) -> Result<Value, Error> { fn author(&self, params: Params) -> Result<Value, Error> {
match params { match params {
Params::None => to_value(&Address::new()), Params::None => to_value(&take_weak!(self.miner).author()),
_ => Err(Error::invalid_params()) _ => Err(Error::invalid_params()),
} }
} }