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_dns(
engine: Arc<Engine>,
identity: Keypair,
(listen, announce): (Option<Multiaddr>, Vec<Multiaddr>),
dns: DnsMode,
) -> Result<Self, Error>
pub fn start_with_dns( engine: Arc<Engine>, identity: Keypair, (listen, announce): (Option<Multiaddr>, Vec<Multiaddr>), dns: DnsMode, ) -> Result<Self, Error>
As start, with the name resolution mode explicit; DnsMode::Refuse
stands in for an unreadable system resolver configuration.
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 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 an address (with or without /p2p), then probe the peer with a
zero-limit Peers request. Returns the authenticated identity; the
connection stays for later requests. A Busy probe is an error that keeps
the connection; any other failed probe closes it: the peer is on another
chain or does not speak this protocol.
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<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