removed try_seal from MinerClient interface (#1262)

This commit is contained in:
Marek Kotewicz 2016-06-13 09:51:14 -07:00 committed by Gav Wood
parent a8831fe896
commit 4ef4819bf9
5 changed files with 4 additions and 17 deletions

View File

@ -785,10 +785,6 @@ impl<V> MiningBlockChainClient for Client<V> where V: Verifier {
open_block 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 { impl MayPanic for Client {

View File

@ -36,7 +36,7 @@ use util::hash::{Address, H256, H2048};
use util::numbers::U256; use util::numbers::U256;
use blockchain::TreeRoute; use blockchain::TreeRoute;
use block_queue::BlockQueueInfo; use block_queue::BlockQueueInfo;
use block::{LockedBlock, SealedBlock, OpenBlock}; use block::OpenBlock;
use header::{BlockNumber, Header}; use header::{BlockNumber, Header};
use transaction::{LocalizedTransaction, SignedTransaction}; use transaction::{LocalizedTransaction, SignedTransaction};
use log_entry::LocalizedLogEntry; use log_entry::LocalizedLogEntry;
@ -197,9 +197,6 @@ pub trait BlockChainClient : Sync + Send {
/// Extended client interface used for mining /// Extended client interface used for mining
pub trait MiningBlockChainClient : BlockChainClient { 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. /// Returns OpenBlock prepared for closing.
fn prepare_open_block(&self, author: Address, gas_floor_target: U256, extra_data: Bytes) fn prepare_open_block(&self, author: Address, gas_floor_target: U256, extra_data: Bytes)
-> OpenBlock; -> OpenBlock;

View File

@ -31,7 +31,7 @@ use evm::Factory as EvmFactory;
use miner::{Miner, MinerService}; use miner::{Miner, MinerService};
use block_queue::BlockQueueInfo; use block_queue::BlockQueueInfo;
use block::{SealedBlock, LockedBlock, OpenBlock}; use block::OpenBlock;
use executive::Executed; use executive::Executed;
use error::{ExecutionError}; use error::{ExecutionError};
use trace::LocalizedTrace; use trace::LocalizedTrace;
@ -240,11 +240,6 @@ impl TestBlockChainClient {
} }
impl MiningBlockChainClient for 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 { fn prepare_open_block(&self, _author: Address, _gas_floor_target: U256, _extra_data: Bytes) -> OpenBlock {
unimplemented!(); unimplemented!();
} }

View File

@ -181,7 +181,7 @@ impl Miner {
}); });
if let Some(seal) = s { if let Some(seal) = s {
trace!(target: "miner", "prepare_sealing: managed internal seal. importing..."); 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()) { if let Ok(_) = chain.import_block(sealed.rlp_bytes()) {
trace!(target: "miner", "prepare_sealing: sealed internally and imported. leaving."); trace!(target: "miner", "prepare_sealing: sealed internally and imported. leaving.");
} else { } else {
@ -510,7 +510,7 @@ impl MinerService for Miner {
fn submit_seal(&self, chain: &MiningBlockChainClient, pow_hash: H256, seal: Vec<Bytes>) -> Result<(), Error> { 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) { 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(_) => { Err(_) => {
info!(target: "miner", "Mined block rejected, PoW was invalid."); info!(target: "miner", "Mined block rejected, PoW was invalid.");
Err(Error::PowInvalid) Err(Error::PowInvalid)

View File

@ -140,5 +140,4 @@ fn can_mine() {
let b = client.prepare_open_block(Address::default(), 31415926.into(), vec![]).close(); 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_eq!(*b.block().header().parent_hash(), BlockView::new(&dummy_blocks[0]).header_view().sha3());
assert!(client.try_seal(b.lock(), vec![]).is_ok());
} }