mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 09:51:10 +00:00
Remove DiscoveryNetBehaviour trait (#5430)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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};
|
||||
|
||||
@@ -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<Item = PeerId>);
|
||||
}
|
||||
|
||||
@@ -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::utils::interval;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::prelude::*;
|
||||
@@ -1582,6 +1582,13 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
|
||||
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<Item = PeerId>) {
|
||||
self.behaviour.add_discovered_nodes(peer_ids)
|
||||
}
|
||||
|
||||
pub fn finality_proof_import_result(
|
||||
&mut self,
|
||||
request_block: (B::Hash, NumberFor<B>),
|
||||
@@ -2205,12 +2212,6 @@ impl<B: BlockT, H: ExHashT> NetworkBehaviour for Protocol<B, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT, H: ExHashT> DiscoveryNetBehaviour for Protocol<B, H> {
|
||||
fn add_discovered_nodes(&mut self, peer_ids: impl Iterator<Item = PeerId>) {
|
||||
self.behaviour.add_discovered_nodes(peer_ids)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT, H: ExHashT> Drop for Protocol<B, H> {
|
||||
fn drop(&mut self) {
|
||||
debug!(target: "sync", "Network stats:\n{}", self.format_stats());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user