diff --git a/Cargo.lock b/Cargo.lock index 56bd823c1..14ebabb6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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)", diff --git a/Cargo.toml b/Cargo.toml index e468799ea..f281cb854 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/miner/src/lib.rs b/miner/src/lib.rs index ca25e3993..06faf057e 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -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(&self, transactions: Vec, fetch_account: T) -> Vec> where T: Fn(&Address) -> AccountDetails; diff --git a/miner/src/miner.rs b/miner/src/miner.rs index e1b314d57..d4f6c8a00 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -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(&self, transactions: Vec, fetch_account: T) -> Vec> where T: Fn(&Address) -> AccountDetails { let mut transaction_queue = self.transaction_queue.lock().unwrap(); diff --git a/parity/main.rs b/parity/main.rs index e029124c4..731bba9a1 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -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"))] diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 963afbecb..a065392d5 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -232,8 +232,8 @@ impl Eth for EthClient // TODO: do not hardcode author. fn author(&self, params: Params) -> Result { 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()), } }