Moving block sealing and transaction_queue to separate create
This commit is contained in:
@@ -18,6 +18,7 @@ ethcore-util = { path = "../util" }
|
||||
ethcore = { path = "../ethcore" }
|
||||
ethash = { path = "../ethash" }
|
||||
ethsync = { path = "../sync" }
|
||||
ethminer = { path = "../miner" }
|
||||
clippy = { version = "0.0.44", optional = true }
|
||||
rustc-serialize = "0.3"
|
||||
transient-hashmap = "0.1"
|
||||
|
||||
@@ -27,6 +27,7 @@ extern crate jsonrpc_http_server;
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore;
|
||||
extern crate ethsync;
|
||||
extern crate ethminer;
|
||||
extern crate transient_hashmap;
|
||||
|
||||
use self::jsonrpc_core::{IoHandler, IoDelegate};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Weak, Mutex, RwLock};
|
||||
use ethsync::{EthSync, SyncState};
|
||||
use ethminer::{EthMiner};
|
||||
use jsonrpc_core::*;
|
||||
use util::numbers::*;
|
||||
use util::sha3::*;
|
||||
@@ -36,15 +37,17 @@ use v1::helpers::{PollFilter, PollManager};
|
||||
pub struct EthClient {
|
||||
client: Weak<Client>,
|
||||
sync: Weak<EthSync>,
|
||||
miner: Weak<EthMiner>,
|
||||
hashrates: RwLock<HashMap<H256, u64>>,
|
||||
}
|
||||
|
||||
impl EthClient {
|
||||
/// Creates new EthClient.
|
||||
pub fn new(client: &Arc<Client>, sync: &Arc<EthSync>) -> Self {
|
||||
pub fn new(client: &Arc<Client>, sync: &Arc<EthSync>, miner: &Arc<EthMiner>) -> Self {
|
||||
EthClient {
|
||||
client: Arc::downgrade(client),
|
||||
sync: Arc::downgrade(sync),
|
||||
miner: Arc::downgrade(miner),
|
||||
hashrates: RwLock::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
@@ -220,8 +223,8 @@ impl Eth for EthClient {
|
||||
fn work(&self, params: Params) -> Result<Value, Error> {
|
||||
match params {
|
||||
Params::None => {
|
||||
let c = take_weak!(self.client);
|
||||
let u = c.sealing_block().lock().unwrap();
|
||||
let miner = take_weak!(self.miner);
|
||||
let u = miner.sealing_block().lock().unwrap();
|
||||
match *u {
|
||||
Some(ref b) => {
|
||||
let pow_hash = b.hash();
|
||||
@@ -239,9 +242,9 @@ impl Eth for EthClient {
|
||||
fn submit_work(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(H64, H256, H256)>(params).and_then(|(nonce, pow_hash, mix_hash)| {
|
||||
// trace!("Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
|
||||
let c = take_weak!(self.client);
|
||||
let miner = take_weak!(self.miner);
|
||||
let seal = vec![encode(&mix_hash).to_vec(), encode(&nonce).to_vec()];
|
||||
let r = c.submit_seal(pow_hash, seal);
|
||||
let r = miner.submit_seal(pow_hash, seal);
|
||||
to_value(&r.is_ok())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user