add new client messaging
This commit is contained in:
parent
802d5c669d
commit
45027ea306
@ -576,6 +576,11 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
@ -1231,9 +1236,7 @@ impl BlockChainClient for Client {
|
||||
|
||||
// TODO: Make it an actual queue, return errors.
|
||||
fn queue_infinity_message(&self, message: Bytes) {
|
||||
if let Ok(new_message) = self.engine.handle_message(UntrustedRlp::new(&message)) {
|
||||
self.notify(|notify| notify.broadcast(new_message.clone()));
|
||||
}
|
||||
self.engine.handle_message(UntrustedRlp::new(&message));
|
||||
}
|
||||
|
||||
fn signing_network_id(&self) -> Option<u8> {
|
||||
|
@ -52,6 +52,8 @@ pub enum ClientIoMessage {
|
||||
UpdateSealing,
|
||||
/// Submit seal (useful for internal sealing).
|
||||
SubmitSeal(H256, Vec<Bytes>),
|
||||
/// Broadcast a message to the network.
|
||||
BroadcastMessage(Bytes)
|
||||
}
|
||||
|
||||
/// Client service setup. Creates and registers client and network services with the IO subsystem.
|
||||
@ -222,11 +224,15 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
|
||||
},
|
||||
ClientIoMessage::UpdateSealing => {
|
||||
trace!(target: "poa", "message: UpdateSealing");
|
||||
self.client.update_sealing()
|
||||
self.client.update_sealing();
|
||||
},
|
||||
ClientIoMessage::SubmitSeal(ref hash, ref seal) => {
|
||||
trace!(target: "poa", "message: SubmitSeal");
|
||||
self.client.submit_seal(*hash, seal.clone())
|
||||
self.client.submit_seal(*hash, seal.clone());
|
||||
},
|
||||
ClientIoMessage::BroadcastMessage(ref message) => {
|
||||
trace!(target: "poa", "message: BroadcastMessage");
|
||||
self.client.broadcast_message(message.clone());
|
||||
},
|
||||
_ => {} // ignore other messages
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user