move Sealing methods to MiningBlockChainClient
This commit is contained in:
parent
239ba61a99
commit
b9909da8b1
@ -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(
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -667,7 +667,7 @@ mod tests {
|
||||
use super::*;
|
||||
use super::message::*;
|
||||
|
||||
/// Accounts inserted with "1" and "2" are authorities. First proposer is "0".
|
||||
/// Accounts inserted with "0" and "1" are authorities. First proposer is "0".
|
||||
fn setup() -> (Spec, Arc<AccountProvider>) {
|
||||
let tap = Arc::new(AccountProvider::transient_provider());
|
||||
let spec = Spec::new_test_tendermint();
|
||||
|
@ -21,7 +21,7 @@ use rlp::{UntrustedRlp, View};
|
||||
use io::*;
|
||||
use spec::Spec;
|
||||
use error::*;
|
||||
use client::{Client, ClientConfig, ChainNotify};
|
||||
use client::{Client, MiningBlockChainClient, ClientConfig, ChainNotify};
|
||||
use miner::Miner;
|
||||
use snapshot::ManifestData;
|
||||
use snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
||||
|
Loading…
Reference in New Issue
Block a user