Client trait reorg
This commit is contained in:
parent
f3af0f46be
commit
b6c7ed24b7
@ -1294,6 +1294,11 @@ impl BlockChainClient for Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn broadcast_consensus_message(&self, message: Bytes) {
|
||||||
|
self.notify(|notify| notify.broadcast(message.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn signing_network_id(&self) -> Option<u64> {
|
fn signing_network_id(&self) -> Option<u64> {
|
||||||
self.engine.signing_network_id(&self.latest_env_info())
|
self.engine.signing_network_id(&self.latest_env_info())
|
||||||
}
|
}
|
||||||
@ -1360,10 +1365,6 @@ impl MiningBlockChainClient for Client {
|
|||||||
&self.factories.vm
|
&self.factories.vm
|
||||||
}
|
}
|
||||||
|
|
||||||
fn broadcast_message(&self, message: Bytes) {
|
|
||||||
self.notify(|notify| notify.broadcast(message.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_sealing(&self) {
|
fn update_sealing(&self) {
|
||||||
self.miner.update_sealing(self)
|
self.miner.update_sealing(self)
|
||||||
}
|
}
|
||||||
|
@ -363,8 +363,6 @@ impl MiningBlockChainClient for TestBlockChainClient {
|
|||||||
|
|
||||||
fn broadcast_proposal_block(&self, _block: SealedBlock) {}
|
fn broadcast_proposal_block(&self, _block: SealedBlock) {}
|
||||||
|
|
||||||
fn broadcast_message(&self, _message: Bytes) {}
|
|
||||||
|
|
||||||
fn update_sealing(&self) {
|
fn update_sealing(&self) {
|
||||||
self.miner.update_sealing(self)
|
self.miner.update_sealing(self)
|
||||||
}
|
}
|
||||||
@ -681,6 +679,8 @@ impl BlockChainClient for TestBlockChainClient {
|
|||||||
self.spec.engine.handle_message(UntrustedRlp::new(&message)).unwrap();
|
self.spec.engine.handle_message(UntrustedRlp::new(&message)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn broadcast_consensus_message(&self, _message: Bytes) {}
|
||||||
|
|
||||||
fn pending_transactions(&self) -> Vec<SignedTransaction> {
|
fn pending_transactions(&self) -> Vec<SignedTransaction> {
|
||||||
self.miner.pending_transactions(self.chain_info().best_block_number)
|
self.miner.pending_transactions(self.chain_info().best_block_number)
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,9 @@ pub trait BlockChainClient : Sync + Send {
|
|||||||
/// Queue conensus engine message.
|
/// Queue conensus engine message.
|
||||||
fn queue_consensus_message(&self, message: Bytes);
|
fn queue_consensus_message(&self, message: Bytes);
|
||||||
|
|
||||||
|
/// Used by PoA to communicate with peers.
|
||||||
|
fn broadcast_consensus_message(&self, message: Bytes);
|
||||||
|
|
||||||
/// list all transactions
|
/// list all transactions
|
||||||
fn pending_transactions(&self) -> Vec<SignedTransaction>;
|
fn pending_transactions(&self) -> Vec<SignedTransaction>;
|
||||||
|
|
||||||
@ -282,9 +285,6 @@ pub trait MiningBlockChainClient: BlockChainClient {
|
|||||||
/// Used by PoA to submit gathered signatures.
|
/// Used by PoA to submit gathered signatures.
|
||||||
fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>);
|
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.
|
/// Broadcast a block proposal.
|
||||||
fn broadcast_proposal_block(&self, block: SealedBlock);
|
fn broadcast_proposal_block(&self, block: SealedBlock);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ use rlp::{UntrustedRlp, View};
|
|||||||
use io::*;
|
use io::*;
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use error::*;
|
use error::*;
|
||||||
use client::{Client, MiningBlockChainClient, ClientConfig, ChainNotify};
|
use client::{Client, BlockChainClient, MiningBlockChainClient, ClientConfig, ChainNotify};
|
||||||
use miner::Miner;
|
use miner::Miner;
|
||||||
use snapshot::ManifestData;
|
use snapshot::ManifestData;
|
||||||
use snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
use snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
||||||
@ -29,8 +29,6 @@ use std::sync::atomic::AtomicBool;
|
|||||||
|
|
||||||
#[cfg(feature="ipc")]
|
#[cfg(feature="ipc")]
|
||||||
use nanoipc;
|
use nanoipc;
|
||||||
#[cfg(feature="ipc")]
|
|
||||||
use client::BlockChainClient;
|
|
||||||
|
|
||||||
/// Message type for external and internal events
|
/// Message type for external and internal events
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
@ -227,7 +225,7 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
|
|||||||
},
|
},
|
||||||
ClientIoMessage::UpdateSealing => self.client.update_sealing(),
|
ClientIoMessage::UpdateSealing => self.client.update_sealing(),
|
||||||
ClientIoMessage::SubmitSeal(ref hash, ref seal) => self.client.submit_seal(*hash, seal.clone()),
|
ClientIoMessage::SubmitSeal(ref hash, ref seal) => self.client.submit_seal(*hash, seal.clone()),
|
||||||
ClientIoMessage::BroadcastMessage(ref message) => self.client.broadcast_message(message.clone()),
|
ClientIoMessage::BroadcastMessage(ref message) => self.client.broadcast_consensus_message(message.clone()),
|
||||||
ClientIoMessage::NewMessage(ref message) => if let Err(e) = self.client.engine().handle_message(UntrustedRlp::new(message)) {
|
ClientIoMessage::NewMessage(ref message) => if let Err(e) = self.client.engine().handle_message(UntrustedRlp::new(message)) {
|
||||||
trace!(target: "poa", "Invalid message received: {}", e);
|
trace!(target: "poa", "Invalid message received: {}", e);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user