Merge pull request #800 from ethcore/fixjsonrpc
Increase threads to num_cpus & fix author reporting
This commit is contained in:
commit
ebd7273071
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -15,6 +15,7 @@ dependencies = [
|
||||
"ethsync 1.1.0",
|
||||
"fdlimit 0.1.0",
|
||||
"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)",
|
||||
"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)",
|
||||
|
@ -18,6 +18,7 @@ time = "0.1"
|
||||
ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" }
|
||||
fdlimit = { path = "util/fdlimit" }
|
||||
daemonize = "0.2"
|
||||
num_cpus = "0.2"
|
||||
number_prefix = "0.2"
|
||||
rpassword = "0.1"
|
||||
clippy = { version = "0.0.54", optional = true }
|
||||
|
@ -65,7 +65,7 @@ pub use transaction_queue::{TransactionQueue, AccountDetails};
|
||||
pub use miner::{Miner};
|
||||
|
||||
use std::sync::Mutex;
|
||||
use util::{H256, Address, Bytes};
|
||||
use util::{H256, Address, FixedHash, Bytes};
|
||||
use ethcore::client::{BlockChainClient};
|
||||
use ethcore::block::{ClosedBlock};
|
||||
use ethcore::error::{Error};
|
||||
@ -77,6 +77,12 @@ pub trait MinerService : Send + Sync {
|
||||
/// Returns miner's status.
|
||||
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.
|
||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) -> Vec<Result<(), Error>>
|
||||
where T: Fn(&Address) -> AccountDetails;
|
||||
|
@ -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>>
|
||||
where T: Fn(&Address) -> AccountDetails {
|
||||
let mut transaction_queue = self.transaction_queue.lock().unwrap();
|
||||
|
@ -20,6 +20,7 @@
|
||||
#![cfg_attr(feature="dev", feature(plugin))]
|
||||
#![cfg_attr(feature="dev", plugin(clippy))]
|
||||
extern crate docopt;
|
||||
extern crate num_cpus;
|
||||
extern crate rustc_serialize;
|
||||
extern crate ethcore_util as util;
|
||||
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"))]
|
||||
|
@ -232,8 +232,8 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
||||
// TODO: do not hardcode author.
|
||||
fn author(&self, params: Params) -> Result<Value, Error> {
|
||||
match params {
|
||||
Params::None => to_value(&Address::new()),
|
||||
_ => Err(Error::invalid_params())
|
||||
Params::None => to_value(&take_weak!(self.miner).author()),
|
||||
_ => Err(Error::invalid_params()),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user