From 77cef765183491e69d53210258824c43e22bf5d0 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 31 May 2016 21:31:42 +0200 Subject: [PATCH] rpc bindings resolved --- parity/dapps.rs | 2 +- parity/main.rs | 2 +- parity/rpc.rs | 2 +- parity/signer.rs | 2 +- rpc/src/lib.rs | 1 - rpc/src/v1/impls/eth.rs | 16 +++++++------- rpc/src/v1/impls/ethcore.rs | 2 +- rpc/src/v1/impls/mod.rs | 10 ++++----- rpc/src/v1/impls/personal.rs | 10 ++++----- rpc/src/v1/tests/eth.rs | 6 +++--- rpc/src/v1/tests/helpers/miner_service.rs | 26 +++++++++++------------ rpc/src/v1/tests/mocked/eth.rs | 2 +- rpc/src/v1/tests/mocked/ethcore.rs | 2 +- sync/src/chain.rs | 2 +- sync/src/tests/helpers.rs | 2 +- 15 files changed, 43 insertions(+), 44 deletions(-) diff --git a/parity/dapps.rs b/parity/dapps.rs index 986e3dd07..7909bb9bc 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -19,7 +19,7 @@ use std::str::FromStr; use std::net::SocketAddr; use ethcore::client::Client; use ethsync::EthSync; -use ethminer::{Miner, ExternalMiner}; +use ethcore::miner::{Miner, ExternalMiner}; use util::RotatingLogger; use util::panics::PanicHandler; use util::keys::store::AccountService; diff --git a/parity/main.rs b/parity/main.rs index 7f16d28a5..539797fb9 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -85,7 +85,7 @@ use ethcore::error::{Error, ImportError}; use ethcore::service::ClientService; use ethcore::spec::Spec; use ethsync::EthSync; -use ethminer::{Miner, MinerService, ExternalMiner}; +use ethcore::miner::{Miner, MinerService, ExternalMiner}; use daemonize::Daemonize; use migration::migrate; use informant::Informant; diff --git a/parity/rpc.rs b/parity/rpc.rs index 60766263b..0d8d7562e 100644 --- a/parity/rpc.rs +++ b/parity/rpc.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use std::net::SocketAddr; use ethcore::client::Client; use ethsync::EthSync; -use ethminer::{Miner, ExternalMiner}; +use ethcore::miner::{Miner, ExternalMiner}; use util::RotatingLogger; use util::panics::PanicHandler; use util::keys::store::AccountService; diff --git a/parity/signer.rs b/parity/signer.rs index 5e3339bcc..3f6197e3a 100644 --- a/parity/signer.rs +++ b/parity/signer.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use ethcore::client::Client; use ethsync::EthSync; -use ethminer::{Miner, ExternalMiner}; +use ethcore::miner::{Miner, ExternalMiner}; use util::keys::store::AccountService; use util::panics::{PanicHandler, ForwardPanic}; use die::*; diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 24d58819c..80c92388a 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -29,7 +29,6 @@ extern crate jsonrpc_http_server; extern crate ethcore_util as util; extern crate ethcore; extern crate ethsync; -extern crate ethminer; extern crate transient_hashmap; extern crate json_ipc_server as ipc; diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index a57fc333c..ad15fb2f7 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -22,13 +22,13 @@ use std::collections::HashSet; use std::sync::{Arc, Weak, Mutex}; use std::ops::Deref; use ethsync::{SyncProvider, SyncState}; -use ethminer::{MinerService, ExternalMinerService}; +use ethcore::miner::{MinerService, ExternalMinerService}; use jsonrpc_core::*; use util::numbers::*; use util::sha3::*; use util::rlp::{encode, decode, UntrustedRlp, View}; use util::keys::store::AccountProvider; -use ethcore::client::{BlockChainClient, BlockID, TransactionID, UncleID}; +use ethcore::client::{MiningBlockChainClient, BlockID, TransactionID, UncleID}; use ethcore::block::IsBlock; use ethcore::views::*; use ethcore::ethereum::Ethash; @@ -44,7 +44,7 @@ use serde; /// Eth rpc implementation. pub struct EthClient where - C: BlockChainClient, + C: MiningBlockChainClient, S: SyncProvider, A: AccountProvider, M: MinerService, @@ -59,7 +59,7 @@ pub struct EthClient where } impl EthClient where - C: BlockChainClient, + C: MiningBlockChainClient, S: SyncProvider, A: AccountProvider, M: MinerService, @@ -224,7 +224,7 @@ fn make_unsupported_err() -> Error { } impl Eth for EthClient where - C: BlockChainClient + 'static, + C: MiningBlockChainClient + 'static, S: SyncProvider + 'static, A: AccountProvider + 'static, M: MinerService + 'static, @@ -566,7 +566,7 @@ impl Eth for EthClient where /// Eth filter rpc implementation. pub struct EthFilterClient where - C: BlockChainClient, + C: MiningBlockChainClient, M: MinerService { client: Weak, @@ -575,7 +575,7 @@ pub struct EthFilterClient where } impl EthFilterClient where - C: BlockChainClient, + C: MiningBlockChainClient, M: MinerService { /// Creates new Eth filter client. @@ -589,7 +589,7 @@ impl EthFilterClient where } impl EthFilter for EthFilterClient where - C: BlockChainClient + 'static, + C: MiningBlockChainClient + 'static, M: MinerService + 'static { fn new_filter(&self, params: Params) -> Result { diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index f5d6f1fda..e649e37f4 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -22,7 +22,7 @@ use std::sync::{Arc, Weak}; use std::ops::Deref; use std::collections::BTreeMap; use jsonrpc_core::*; -use ethminer::MinerService; +use ethcore::miner::MinerService; use v1::traits::Ethcore; use v1::types::Bytes; diff --git a/rpc/src/v1/impls/mod.rs b/rpc/src/v1/impls/mod.rs index 7ee8b8b8a..2f1c07ff6 100644 --- a/rpc/src/v1/impls/mod.rs +++ b/rpc/src/v1/impls/mod.rs @@ -47,8 +47,8 @@ pub use self::rpc::RpcClient; use v1::types::TransactionRequest; use std::sync::Weak; -use ethminer::{AccountDetails, MinerService}; -use ethcore::client::BlockChainClient; +use ethcore::miner::{AccountDetails, MinerService}; +use ethcore::client::MiningBlockChainClient; use ethcore::transaction::{Action, SignedTransaction, Transaction}; use util::numbers::*; use util::rlp::encode; @@ -56,7 +56,7 @@ use util::bytes::ToPretty; use jsonrpc_core::{Error, to_value, Value}; fn dispatch_transaction(client: &C, miner: &M, signed_transaction: SignedTransaction) -> Result - where C: BlockChainClient, M: MinerService { + where C: MiningBlockChainClient, M: MinerService { let hash = signed_transaction.hash(); let import = miner.import_own_transaction(client, signed_transaction, |a: &Address| { @@ -70,7 +70,7 @@ fn dispatch_transaction(client: &C, miner: &M, signed_transaction: SignedT } fn sign_and_dispatch(client: &Weak, miner: &Weak, request: TransactionRequest, secret: H256) -> Result - where C: BlockChainClient, M: MinerService { + where C: MiningBlockChainClient, M: MinerService { let client = take_weak!(client); let miner = take_weak!(miner); @@ -92,4 +92,4 @@ fn sign_and_dispatch(client: &Weak, miner: &Weak, request: Transacti trace!(target: "miner", "send_transaction: dispatching tx: {}", encode(&signed_transaction).to_vec().pretty()); dispatch_transaction(&*client, &*miner, signed_transaction) -} \ No newline at end of file +} diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index 19e902996..074bb8c77 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -22,19 +22,19 @@ use v1::types::TransactionRequest; use v1::impls::sign_and_dispatch; use util::keys::store::*; use util::numbers::*; -use ethcore::client::BlockChainClient; -use ethminer::MinerService; +use ethcore::client::MiningBlockChainClient; +use ethcore::miner::MinerService; /// Account management (personal) rpc implementation. pub struct PersonalClient - where A: AccountProvider, C: BlockChainClient, M: MinerService { + where A: AccountProvider, C: MiningBlockChainClient, M: MinerService { accounts: Weak, client: Weak, miner: Weak, } impl PersonalClient - where A: AccountProvider, C: BlockChainClient, M: MinerService { + where A: AccountProvider, C: MiningBlockChainClient, M: MinerService { /// Creates new PersonalClient pub fn new(store: &Arc, client: &Arc, miner: &Arc) -> Self { PersonalClient { @@ -46,7 +46,7 @@ impl PersonalClient } impl Personal for PersonalClient - where A: AccountProvider, C: BlockChainClient, M: MinerService { + where A: AccountProvider, C: MiningBlockChainClient, M: MinerService { fn accounts(&self, _: Params) -> Result { let store = take_weak!(self.accounts); match store.accounts() { diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 80a856aca..7f5d5e333 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -19,12 +19,12 @@ use std::collections::HashMap; use std::sync::Arc; use std::str::FromStr; -use ethcore::client::{BlockChainClient, Client, ClientConfig}; +use ethcore::client::{MiningBlockChainClient, Client, ClientConfig}; use ethcore::spec::Genesis; use ethcore::block::Block; use ethcore::ethereum; use ethcore::transaction::{Transaction, Action}; -use ethminer::{MinerService, ExternalMiner}; +use ethcore::miner::{MinerService, ExternalMiner}; use devtools::RandomTempPath; use util::io::IoChannel; use util::hash::Address; @@ -38,7 +38,7 @@ use v1::impls::EthClient; use v1::tests::helpers::{TestSyncProvider, Config, TestMinerService}; struct EthTester { - _client: Arc, + _client: Arc, _miner: Arc, accounts: Arc, handler: IoHandler, diff --git a/rpc/src/v1/tests/helpers/miner_service.rs b/rpc/src/v1/tests/helpers/miner_service.rs index 600f88508..a53ca3a08 100644 --- a/rpc/src/v1/tests/helpers/miner_service.rs +++ b/rpc/src/v1/tests/helpers/miner_service.rs @@ -19,11 +19,11 @@ use util::{Address, H256, Bytes, U256, FixedHash, Uint}; use util::standard::*; use ethcore::error::{Error, ExecutionError}; -use ethcore::client::{BlockChainClient, Executed}; +use ethcore::client::{MiningBlockChainClient, Executed}; use ethcore::block::{ClosedBlock, IsBlock}; use ethcore::transaction::SignedTransaction; use ethcore::receipt::Receipt; -use ethminer::{MinerService, MinerStatus, AccountDetails, TransactionImportResult}; +use ethcore::miner::{MinerService, MinerStatus, AccountDetails, TransactionImportResult}; /// Test miner service. pub struct TestMinerService { @@ -132,7 +132,7 @@ impl MinerService for TestMinerService { } /// Imports transactions to transaction queue. - fn import_own_transaction(&self, chain: &BlockChainClient, transaction: SignedTransaction, _fetch_account: T) -> + fn import_own_transaction(&self, chain: &MiningBlockChainClient, transaction: SignedTransaction, _fetch_account: T) -> Result where T: Fn(&Address) -> AccountDetails { @@ -154,21 +154,21 @@ impl MinerService for TestMinerService { } /// Removes all transactions from the queue and restart mining operation. - fn clear_and_reset(&self, _chain: &BlockChainClient) { + fn clear_and_reset(&self, _chain: &MiningBlockChainClient) { unimplemented!(); } /// Called when blocks are imported to chain, updates transactions queue. - fn chain_new_blocks(&self, _chain: &BlockChainClient, _imported: &[H256], _invalid: &[H256], _enacted: &[H256], _retracted: &[H256]) { + fn chain_new_blocks(&self, _chain: &MiningBlockChainClient, _imported: &[H256], _invalid: &[H256], _enacted: &[H256], _retracted: &[H256]) { unimplemented!(); } /// New chain head event. Restart mining operation. - fn update_sealing(&self, _chain: &BlockChainClient) { + fn update_sealing(&self, _chain: &MiningBlockChainClient) { unimplemented!(); } - fn map_sealing_work(&self, _chain: &BlockChainClient, _f: F) -> Option where F: FnOnce(&ClosedBlock) -> T { + fn map_sealing_work(&self, _chain: &MiningBlockChainClient, _f: F) -> Option where F: FnOnce(&ClosedBlock) -> T { unimplemented!(); } @@ -194,29 +194,29 @@ impl MinerService for TestMinerService { /// Submit `seal` as a valid solution for the header of `pow_hash`. /// Will check the seal, but not actually insert the block into the chain. - fn submit_seal(&self, _chain: &BlockChainClient, _pow_hash: H256, _seal: Vec) -> Result<(), Error> { + fn submit_seal(&self, _chain: &MiningBlockChainClient, _pow_hash: H256, _seal: Vec) -> Result<(), Error> { unimplemented!(); } - fn balance(&self, _chain: &BlockChainClient, address: &Address) -> U256 { + fn balance(&self, _chain: &MiningBlockChainClient, address: &Address) -> U256 { self.latest_closed_block.lock().unwrap().as_ref().map_or_else(U256::zero, |b| b.block().fields().state.balance(address).clone()) } - fn call(&self, _chain: &BlockChainClient, _t: &SignedTransaction) -> Result { + fn call(&self, _chain: &MiningBlockChainClient, _t: &SignedTransaction) -> Result { unimplemented!(); } - fn storage_at(&self, _chain: &BlockChainClient, address: &Address, position: &H256) -> H256 { + fn storage_at(&self, _chain: &MiningBlockChainClient, address: &Address, position: &H256) -> H256 { self.latest_closed_block.lock().unwrap().as_ref().map_or_else(H256::default, |b| b.block().fields().state.storage_at(address, position).clone()) } - fn nonce(&self, _chain: &BlockChainClient, address: &Address) -> U256 { + fn nonce(&self, _chain: &MiningBlockChainClient, address: &Address) -> U256 { // we assume all transactions are in a pending block, ignoring the // reality of gas limits. self.last_nonce(address).unwrap_or(U256::zero()) } - fn code(&self, _chain: &BlockChainClient, address: &Address) -> Option { + fn code(&self, _chain: &MiningBlockChainClient, address: &Address) -> Option { self.latest_closed_block.lock().unwrap().as_ref().map_or(None, |b| b.block().fields().state.code(address).clone()) } diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index c51d6d7da..579f57e6c 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -25,7 +25,7 @@ use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed, Transaction use ethcore::log_entry::{LocalizedLogEntry, LogEntry}; use ethcore::receipt::LocalizedReceipt; use ethcore::transaction::{Transaction, Action}; -use ethminer::{ExternalMiner, MinerService}; +use ethcore::miner::{ExternalMiner, MinerService}; use ethsync::SyncState; use v1::{Eth, EthClient}; use v1::tests::helpers::{TestSyncProvider, Config, TestMinerService}; diff --git a/rpc/src/v1/tests/mocked/ethcore.rs b/rpc/src/v1/tests/mocked/ethcore.rs index cc822daef..d51545d86 100644 --- a/rpc/src/v1/tests/mocked/ethcore.rs +++ b/rpc/src/v1/tests/mocked/ethcore.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use std::str::FromStr; use jsonrpc_core::IoHandler; use v1::{Ethcore, EthcoreClient}; -use ethminer::MinerService; +use ethcore::miner::MinerService; use v1::tests::helpers::TestMinerService; use util::numbers::*; use rustc_serialize::hex::FromHex; diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 1270f775f..dc397d77d 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1470,7 +1470,7 @@ mod tests { } fn dummy_sync_with_peer(peer_latest_hash: H256, client: &BlockChainClient) -> ChainSync { - let mut sync = ChainSync::new(SyncConfig::default(), Miner::new(false, Spec::new_test()), client); + let mut sync = ChainSync::new(SyncConfig::default(), client); sync.peers.insert(0, PeerInfo { protocol_version: 0, diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index c2e0e2d04..7cde0b54c 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -92,7 +92,7 @@ impl TestNet { }; for _ in 0..n { let chain = TestBlockChainClient::new(); - let sync = ChainSync::new(SyncConfig::default(), Miner::new(false, Spec::new_test()), &chain); + let sync = ChainSync::new(SyncConfig::default(), &chain); net.peers.push(TestPeer { sync: sync, chain: chain,