pub struct PeerNetwork { /* private fields */ }Expand description
Owns one network thread and one bounded archive-reader thread. Drop requests shutdown and joins both. An archive operation already running is not forcibly interrupted. Source handles do not keep the network alive after this owner.
Implementations§
Source§impl PeerNetwork
impl PeerNetwork
Sourcepub fn start(
engine: Arc<Engine>,
identity: Keypair,
listen: Option<Multiaddr>,
announce: Vec<Multiaddr>,
) -> Result<Self, Error>
pub fn start( engine: Arc<Engine>, identity: Keypair, listen: Option<Multiaddr>, announce: Vec<Multiaddr>, ) -> Result<Self, Error>
Listen only when an explicit IP/TCP address is supplied. Port zero is
allowed for an ephemeral listener; returned address includes this PeerId.
Merely constructing source handles never dials. No peer is a seed by default.
announce are operator-chosen public IP/TCP addresses identify advertises.
Sourcepub fn start_with(
engine: Arc<Engine>,
identity: Keypair,
(listen, announce): (Option<Multiaddr>, Vec<Multiaddr>),
(dns, reach): (DnsMode, ReachMode),
) -> Result<Self, Error>
pub fn start_with( engine: Arc<Engine>, identity: Keypair, (listen, announce): (Option<Multiaddr>, Vec<Multiaddr>), (dns, reach): (DnsMode, ReachMode), ) -> Result<Self, Error>
As start, with name resolution and reachability explicit:
DnsMode::Refuse stands in for an unreadable resolver configuration and
ReachMode::Forced for a reachability AutoNAT would conclude.
pub fn peer_id(&self) -> PeerId
Sourcepub fn connected_peers(&self) -> u64
pub fn connected_peers(&self) -> u64
Distinct peers with at least one established connection right now.
pub fn listen_address(&self) -> Option<Multiaddr>
Sourcepub fn listen_addresses(&self) -> Vec<Multiaddr>
pub fn listen_addresses(&self) -> Vec<Multiaddr>
Every address the listener is bound to now, with /p2p.
pub fn source(&self, address: PeerAddress) -> PeerSource
Sourcepub fn sync_peers(&self, manual: Vec<PeerAddress>) -> SyncPeers
pub fn sync_peers(&self, manual: Vec<PeerAddress>) -> SyncPeers
manual peers first, then whoever is connected and on our chain.
pub fn commit_source( &self, chain: Chain, manual: Vec<PeerAddress>, ) -> OverlayCommitSource
pub fn shutdown(self) -> Result<(), Error>
Source§impl PeerNetwork
impl PeerNetwork
Sourcepub fn set_gossip(&self, peers: Vec<GossipPeer>)
pub fn set_gossip(&self, peers: Vec<GossipPeer>)
Replace the snapshot served to Peers requests. Order is preserved; the first entries are the ones a bounded request receives.
Sourcepub fn observed_addrs(&self) -> Vec<Multiaddr>
pub fn observed_addrs(&self) -> Vec<Multiaddr>
Public addresses connected peers reported observing for this node.
Sourcepub fn connected_peer_ids(&self) -> Vec<PeerId>
pub fn connected_peer_ids(&self) -> Vec<PeerId>
Peers with at least one established connection right now, sorted.
Sourcepub fn peer_links(&self) -> Vec<(PeerId, PeerLink)>
pub fn peer_links(&self) -> Vec<(PeerId, PeerLink)>
Connected peers with their link, sorted by peer.
Sourcepub fn has_direct(&self, peer: PeerId) -> bool
pub fn has_direct(&self, peer: PeerId) -> bool
Whether the peer holds a direct connection; relayed-only peers never carry data.
Sourcepub fn can_gossip(&self, peer: PeerId) -> bool
pub fn can_gossip(&self, peer: PeerId) -> bool
Whether Peers gossip can ride an open connection to the peer.
Sourcepub fn any_direct(&self, peer: PeerId) -> bool
pub fn any_direct(&self, peer: PeerId) -> bool
Whether a direct connection that carries records is open to the peer.
pub fn reachability(&self) -> Reachability
Sourcepub fn external_addresses(&self) -> Vec<Multiaddr>
pub fn external_addresses(&self) -> Vec<Multiaddr>
Addresses advertised to peers: AutoNAT-confirmed or announced.
Sourcepub fn reserved_by_others(&self) -> Vec<PeerId>
pub fn reserved_by_others(&self) -> Vec<PeerId>
Peers holding an active reservation on this node’s relay server.
Sourcepub fn circuit_addresses(&self) -> Vec<Multiaddr>
pub fn circuit_addresses(&self) -> Vec<Multiaddr>
This node’s /p2p-circuit listen addresses through its relays.
Sourcepub fn drain_identified(&self) -> Vec<(PeerId, Vec<Multiaddr>)>
pub fn drain_identified(&self) -> Vec<(PeerId, Vec<Multiaddr>)>
Connected peers’ own literal public addresses learned through identify since the last call, newest 64 peers; the queue is emptied.
Sourcepub fn dial(
&self,
address: Multiaddr,
cancelled: &AtomicBool,
deadline: Instant,
) -> Result<PeerId, Error>
pub fn dial( &self, address: Multiaddr, cancelled: &AtomicBool, deadline: Instant, ) -> Result<PeerId, Error>
dial_any for a peer that must be reached directly: a peer reached
only through a relay is a Busy error until DCUtR links it directly.
Sourcepub fn dial_any(
&self,
address: Multiaddr,
cancelled: &AtomicBool,
deadline: Instant,
) -> Result<Dialed, Error>
pub fn dial_any( &self, address: Multiaddr, cancelled: &AtomicBool, deadline: Instant, ) -> Result<Dialed, Error>
Dial an address (with or without /p2p); a direct peer gets the chain
probe. A relayed-only peer is returned unprobed: records/5 never runs
on relayed links. The connection stays for later requests.
Sourcepub fn probe(
&self,
peer: PeerId,
cancelled: &AtomicBool,
deadline: Instant,
) -> Result<PeerId, Error>
pub fn probe( &self, peer: PeerId, cancelled: &AtomicBool, deadline: Instant, ) -> Result<PeerId, Error>
The chain probe: a zero-limit Peers request over a direct link. Only a
peer proven to be elsewhere (probe_closes) loses its connections.
Sourcepub fn peers_of(
&self,
peer: PeerId,
limit: u32,
cancelled: &AtomicBool,
deadline: Instant,
) -> Result<Vec<GossipPeer>, Error>
pub fn peers_of( &self, peer: PeerId, limit: u32, cancelled: &AtomicBool, deadline: Instant, ) -> Result<Vec<GossipPeer>, Error>
One bounded Peers request over an existing connection (or addresses the
swarm already knows). limit is at most PEERS_MAX; 0 is a bare probe.
Trait Implementations§
Source§impl Drop for PeerNetwork
impl Drop for PeerNetwork
Auto Trait Implementations§
impl !RefUnwindSafe for PeerNetwork
impl !UnwindSafe for PeerNetwork
impl Freeze for PeerNetwork
impl Send for PeerNetwork
impl Sync for PeerNetwork
impl Unpin for PeerNetwork
impl UnsafeUnpin for PeerNetwork
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more