mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
Make the behaviour in libp2p generic (#2525)
* Make the behaviour in libp2p generic * Fix indentation * Fix bad merge
This commit is contained in:
committed by
Gavin Wood
parent
2724cdac33
commit
d974189e3c
@@ -57,9 +57,9 @@
|
||||
//!
|
||||
//! Please keep in mind that the state of the [`Service`] only updates itself in a way
|
||||
//! corresponding to the [`ServiceEvent`] that `poll` returns.
|
||||
//!
|
||||
//!
|
||||
//! Illustration:
|
||||
//!
|
||||
//!
|
||||
//! - You call [`Service::connected_peers`] to get the list of nodes we are connected to.
|
||||
//! - If you then call [`Service::connected_peers`] again, the returned list will always be the
|
||||
//! same, no matter what happened on the wire.
|
||||
@@ -119,6 +119,17 @@ use serde::{Deserialize, Serialize};
|
||||
use slog_derive::SerdeValue;
|
||||
use std::{collections::{HashMap, HashSet}, error, fmt, time::Duration};
|
||||
|
||||
/// Extension trait for `NetworkBehaviour` that also accepts discovering nodes.
|
||||
pub 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>);
|
||||
}
|
||||
|
||||
/// Name of a protocol, transmitted on the wire. Should be unique for each chain.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ProtocolId(smallvec::SmallVec<[u8; 6]>);
|
||||
|
||||
Reference in New Issue
Block a user