* Revert #2745

* Fix error in merge resolve

* Fix compilation
This commit is contained in:
Pierre Krieger
2019-06-05 11:56:36 +02:00
committed by Bastian Köcher
parent a5964e4055
commit 89b312fe9c
5 changed files with 11 additions and 35 deletions
+1 -17
View File
@@ -18,6 +18,7 @@
use crate::PeerId;
use runtime_primitives::traits::Block as BlockT;
use crate::protocol::Context;
/// A specialization of the substrate network protocol. Handles events and sends messages.
pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
@@ -50,23 +51,6 @@ pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
fn on_block_imported(&mut self, _ctx: &mut dyn Context<B>, _hash: B::Hash, _header: &B::Header) { }
}
/// Context for a network-specific handler.
pub trait Context<B: BlockT> {
/// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or
/// irresponsible or appeared lazy.
fn report_peer(&mut self, who: PeerId, reputation: i32);
/// Force disconnecting from a peer. Use this when a peer misbehaved.
fn disconnect_peer(&mut self, who: PeerId);
/// Send a consensus message to a peer.
#[deprecated(note = "This method shouldn't have been part of the specialization API")]
fn send_consensus(&mut self, _who: PeerId, _consensus: crate::message::generic::ConsensusMessage) {}
/// Send a chain-specific message to a peer.
fn send_chain_specific(&mut self, who: PeerId, message: Vec<u8>);
}
/// Construct a simple protocol that is composed of several sub protocols.
/// Each "sub protocol" needs to implement `Specialization` and needs to provide a `new()` function.
/// For more fine grained implementations, this macro is not usable.