Remove DiscoveryNetBehaviour trait (#5430)

This commit is contained in:
Pierre Krieger
2020-04-01 17:25:53 +02:00
committed by GitHub
parent 72239adda1
commit 84ff6ef157
4 changed files with 20 additions and 29 deletions
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
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<Item = PeerId>) {
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<Item = PeerId>) {
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;