Replace NodeIndex with PeerId everywhere (#2077)

* Replace NodeIndex with PeerId

* Fix tests

* More test fixing

* Whitespace
This commit is contained in:
Pierre Krieger
2019-03-23 10:34:28 +01:00
committed by Arkadiy Paronyan
parent 6fa40ec199
commit 6e394464b8
20 changed files with 424 additions and 480 deletions
+4 -4
View File
@@ -16,7 +16,7 @@
//! Specializations of the substrate network protocol to allow more complex forms of communication.
use crate::NodeIndex;
use crate::PeerId;
use runtime_primitives::traits::Block as BlockT;
use crate::protocol::Context;
@@ -26,13 +26,13 @@ pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
fn status(&self) -> Vec<u8>;
/// Called when a peer successfully handshakes.
fn on_connect(&mut self, ctx: &mut Context<B>, who: NodeIndex, status: crate::message::Status<B>);
fn on_connect(&mut self, ctx: &mut Context<B>, who: PeerId, status: crate::message::Status<B>);
/// Called when a peer is disconnected. If the peer ID is unknown, it should be ignored.
fn on_disconnect(&mut self, ctx: &mut Context<B>, who: NodeIndex);
fn on_disconnect(&mut self, ctx: &mut Context<B>, who: PeerId);
/// Called when a network-specific message arrives.
fn on_message(&mut self, ctx: &mut Context<B>, who: NodeIndex, message: &mut Option<crate::message::Message<B>>);
fn on_message(&mut self, ctx: &mut Context<B>, who: PeerId, message: &mut Option<crate::message::Message<B>>);
/// Called on abort.
fn on_abort(&mut self) { }