Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
removed try_seal from MinerClient interface (#1262)
Browse files Browse the repository at this point in the history
  • Loading branch information
debris authored and gavofyork committed Jun 13, 2016
1 parent a8831fe commit 4ef4819
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
4 changes: 0 additions & 4 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,6 @@ impl<V> MiningBlockChainClient for Client<V> where V: Verifier {

open_block
}

fn try_seal(&self, block: LockedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock> {
block.try_seal(self.engine.deref().deref(), seal)
}
}

impl MayPanic for Client {
Expand Down
5 changes: 1 addition & 4 deletions ethcore/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use util::hash::{Address, H256, H2048};
use util::numbers::U256;
use blockchain::TreeRoute;
use block_queue::BlockQueueInfo;
use block::{LockedBlock, SealedBlock, OpenBlock};
use block::OpenBlock;
use header::{BlockNumber, Header};
use transaction::{LocalizedTransaction, SignedTransaction};
use log_entry::LocalizedLogEntry;
Expand Down Expand Up @@ -197,9 +197,6 @@ pub trait BlockChainClient : Sync + Send {

/// Extended client interface used for mining
pub trait MiningBlockChainClient : BlockChainClient {
/// Attempts to seal given block. Returns `SealedBlock` on success and the same block in case of error.
fn try_seal(&self, block: LockedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock>;

/// Returns OpenBlock prepared for closing.
fn prepare_open_block(&self, author: Address, gas_floor_target: U256, extra_data: Bytes)
-> OpenBlock;
Expand Down
7 changes: 1 addition & 6 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use evm::Factory as EvmFactory;
use miner::{Miner, MinerService};

use block_queue::BlockQueueInfo;
use block::{SealedBlock, LockedBlock, OpenBlock};
use block::OpenBlock;
use executive::Executed;
use error::{ExecutionError};
use trace::LocalizedTrace;
Expand Down Expand Up @@ -240,11 +240,6 @@ impl TestBlockChainClient {
}

impl MiningBlockChainClient for TestBlockChainClient {
fn try_seal(&self, block: LockedBlock, _seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock> {
Err(block)
}


fn prepare_open_block(&self, _author: Address, _gas_floor_target: U256, _extra_data: Bytes) -> OpenBlock {
unimplemented!();
}
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Miner {
});
if let Some(seal) = s {
trace!(target: "miner", "prepare_sealing: managed internal seal. importing...");
if let Ok(sealed) = chain.try_seal(block.lock(), seal) {
if let Ok(sealed) = block.lock().try_seal(self.engine(), seal) {
if let Ok(_) = chain.import_block(sealed.rlp_bytes()) {
trace!(target: "miner", "prepare_sealing: sealed internally and imported. leaving.");
} else {
Expand Down Expand Up @@ -510,7 +510,7 @@ impl MinerService for Miner {

fn submit_seal(&self, chain: &MiningBlockChainClient, pow_hash: H256, seal: Vec<Bytes>) -> Result<(), Error> {
if let Some(b) = self.sealing_work.lock().unwrap().take_used_if(|b| &b.hash() == &pow_hash) {
match chain.try_seal(b.lock(), seal) {
match b.lock().try_seal(self.engine(), seal) {
Err(_) => {
info!(target: "miner", "Mined block rejected, PoW was invalid.");
Err(Error::PowInvalid)
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,4 @@ fn can_mine() {
let b = client.prepare_open_block(Address::default(), 31415926.into(), vec![]).close();

assert_eq!(*b.block().header().parent_hash(), BlockView::new(&dummy_blocks[0]).header_view().sha3());
assert!(client.try_seal(b.lock(), vec![]).is_ok());
}

0 comments on commit 4ef4819

Please sign in to comment.