diff --git a/substrate/client/network/src/behaviour.rs b/substrate/client/network/src/behaviour.rs
index e7aca1975c..37bc9bfb01 100644
--- a/substrate/client/network/src/behaviour.rs
+++ b/substrate/client/network/src/behaviour.rs
@@ -15,7 +15,7 @@
// along with Substrate. If not, see .
use crate::{
- debug_info, discovery::DiscoveryBehaviour, discovery::DiscoveryOut, DiscoveryNetBehaviour,
+ debug_info, discovery::DiscoveryBehaviour, discovery::DiscoveryOut,
Event, protocol::event::DhtEvent, ExHashT,
};
use crate::protocol::{self, light_client_handler, CustomMessageOutcome, Protocol};
diff --git a/substrate/client/network/src/lib.rs b/substrate/client/network/src/lib.rs
index 23233ee904..bb58f8c7bf 100644
--- a/substrate/client/network/src/lib.rs
+++ b/substrate/client/network/src/lib.rs
@@ -255,14 +255,3 @@ pub use libp2p::{Multiaddr, PeerId};
pub use libp2p::multiaddr;
pub use sc_peerset::ReputationChange;
-
-/// Extension trait for `NetworkBehaviour` that also accepts discovering nodes.
-trait DiscoveryNetBehaviour {
- /// Notify the protocol that we have learned about the existence of nodes.
- ///
- /// Can (or most likely will) be called multiple times with the same `PeerId`s.
- ///
- /// Also note that there is no notification for expired nodes. The implementer must add a TTL
- /// system, or remove nodes that will fail to reach.
- fn add_discovered_nodes(&mut self, nodes: impl Iterator- );
-}
diff --git a/substrate/client/network/src/protocol.rs b/substrate/client/network/src/protocol.rs
index 55bc40a950..d534bde810 100644
--- a/substrate/client/network/src/protocol.rs
+++ b/substrate/client/network/src/protocol.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see .
-use crate::{DiscoveryNetBehaviour, config::ProtocolId};
+use crate::config::ProtocolId;
use crate::utils::interval;
use bytes::{Bytes, BytesMut};
use futures::prelude::*;
@@ -1582,6 +1582,13 @@ impl Protocol {
self.sync.request_finality_proof(&hash, number)
}
+ /// Notify the protocol that we have learned about the existence of nodes.
+ ///
+ /// Can be called multiple times with the same `PeerId`s.
+ pub fn add_discovered_nodes(&mut self, peer_ids: impl Iterator
- ) {
+ self.behaviour.add_discovered_nodes(peer_ids)
+ }
+
pub fn finality_proof_import_result(
&mut self,
request_block: (B::Hash, NumberFor),
@@ -2205,12 +2212,6 @@ impl NetworkBehaviour for Protocol {
}
}
-impl DiscoveryNetBehaviour for Protocol {
- fn add_discovered_nodes(&mut self, peer_ids: impl Iterator
- ) {
- self.behaviour.add_discovered_nodes(peer_ids)
- }
-}
-
impl Drop for Protocol {
fn drop(&mut self) {
debug!(target: "sync", "Network stats:\n{}", self.format_stats());
diff --git a/substrate/client/network/src/protocol/generic_proto/behaviour.rs b/substrate/client/network/src/protocol/generic_proto/behaviour.rs
index 63625f1c9f..e52ac5575f 100644
--- a/substrate/client/network/src/protocol/generic_proto/behaviour.rs
+++ b/substrate/client/network/src/protocol/generic_proto/behaviour.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see .
-use crate::{DiscoveryNetBehaviour, config::ProtocolId};
+use crate::config::ProtocolId;
use crate::protocol::generic_proto::handler::{NotifsHandlerProto, NotifsHandlerOut, NotifsHandlerIn};
use crate::protocol::generic_proto::upgrade::RegisteredProtocol;
@@ -405,6 +405,16 @@ impl GenericProto {
}
}
+ /// Notify the behaviour that we have learned about the existence of nodes.
+ ///
+ /// Can be called multiple times with the same `PeerId`s.
+ pub fn add_discovered_nodes(&mut self, peer_ids: impl Iterator
- ) {
+ self.peerset.discovered(peer_ids.into_iter().map(|peer_id| {
+ debug!(target: "sub-libp2p", "PSM <= Discovered({:?})", peer_id);
+ peer_id
+ }));
+ }
+
/// Sends a notification to a peer.
///
/// Has no effect if the custom protocol is not open with the given peer.
@@ -708,15 +718,6 @@ impl GenericProto {
}
}
-impl DiscoveryNetBehaviour for GenericProto {
- fn add_discovered_nodes(&mut self, peer_ids: impl Iterator
- ) {
- self.peerset.discovered(peer_ids.into_iter().map(|peer_id| {
- debug!(target: "sub-libp2p", "PSM <= Discovered({:?})", peer_id);
- peer_id
- }));
- }
-}
-
impl NetworkBehaviour for GenericProto {
type ProtocolsHandler = NotifsHandlerProto;
type OutEvent = GenericProtoOut;