move Sealing methods to MiningBlockChainClient

This commit is contained in:
keorn
2016-12-10 17:40:20 +01:00
parent 239ba61a99
commit b9909da8b1
5 changed files with 37 additions and 20 deletions

View File

@@ -580,23 +580,6 @@ impl Client {
self.miner.clone()
}
/// Used by PoA to try sealing on period change.
pub fn update_sealing(&self) {
self.miner.update_sealing(self)
}
/// Used by PoA to submit gathered signatures.
pub fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>) {
if self.miner.submit_seal(self, block_hash, seal).is_err() {
warn!(target: "poa", "Wrong internal seal submission!")
}
}
/// Used by PoA to communicate with peers.
pub fn broadcast_message(&self, message: Bytes) {
self.notify(|notify| notify.broadcast(message.clone()));
}
/// Attempt to get a copy of a specific block's final state.
///
/// This will not fail if given BlockID::Latest.
@@ -1335,7 +1318,6 @@ impl BlockChainClient for Client {
}
impl MiningBlockChainClient for Client {
fn latest_schedule(&self) -> Schedule {
self.engine.schedule(&self.latest_env_info())
}
@@ -1378,6 +1360,20 @@ impl MiningBlockChainClient for Client {
&self.factories.vm
}
fn broadcast_message(&self, message: Bytes) {
self.notify(|notify| notify.broadcast(message.clone()));
}
fn update_sealing(&self) {
self.miner.update_sealing(self)
}
fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>) {
if self.miner.submit_seal(self, block_hash, seal).is_err() {
warn!(target: "poa", "Wrong internal seal submission!")
}
}
fn broadcast_proposal_block(&self, block: SealedBlock) {
self.notify(|notify| {
notify.new_blocks(

View File

@@ -362,6 +362,18 @@ impl MiningBlockChainClient for TestBlockChainClient {
}
fn broadcast_proposal_block(&self, _block: SealedBlock) {}
fn broadcast_message(&self, _message: Bytes) {}
fn update_sealing(&self) {
self.miner.update_sealing(self)
}
fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>) {
if self.miner.submit_seal(self, block_hash, seal).is_err() {
warn!(target: "poa", "Wrong internal seal submission!")
}
}
}
impl BlockChainClient for TestBlockChainClient {

View File

@@ -276,6 +276,15 @@ pub trait MiningBlockChainClient: BlockChainClient {
/// Returns EvmFactory.
fn vm_factory(&self) -> &EvmFactory;
/// Used by PoA to try sealing on period change.
fn update_sealing(&self);
/// Used by PoA to submit gathered signatures.
fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>);
/// Used by PoA to communicate with peers.
fn broadcast_message(&self, message: Bytes);
/// Broadcast a block proposal.
fn broadcast_proposal_block(&self, block: SealedBlock);