Skip to main content

PeerNetwork

Struct PeerNetwork 

Source
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

Source

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.

Source

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.

Source

pub fn peer_id(&self) -> PeerId

Source

pub fn connected_peers(&self) -> u64

Distinct peers with at least one established connection right now.

Source

pub fn listen_address(&self) -> Option<Multiaddr>

Source

pub fn dns(&self) -> &Dns

Whether named addresses can be dialed by this overlay.

Source

pub fn listen_addresses(&self) -> Vec<Multiaddr>

Every address the listener is bound to now, with /p2p.

Source

pub fn source(&self, address: PeerAddress) -> PeerSource

Source

pub fn sync_peers(&self, manual: Vec<PeerAddress>) -> SyncPeers

manual peers first, then whoever is connected and on our chain.

Source

pub fn commit_source( &self, chain: Chain, manual: Vec<PeerAddress>, ) -> OverlayCommitSource

Source

pub fn shutdown(self) -> Result<(), Error>

Source§

impl PeerNetwork

Source

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.

Source

pub fn observed_addrs(&self) -> Vec<Multiaddr>

Public addresses connected peers reported observing for this node.

Source

pub fn connected_peer_ids(&self) -> Vec<PeerId>

Peers with at least one established connection right now, sorted.

Connected peers with their link, sorted by peer.

Source

pub fn has_direct(&self, peer: PeerId) -> bool

Whether the peer holds a direct connection; relayed-only peers never carry data.

Source

pub fn can_gossip(&self, peer: PeerId) -> bool

Whether Peers gossip can ride an open connection to the peer.

Source

pub fn any_direct(&self, peer: PeerId) -> bool

Whether a direct connection that carries records is open to the peer.

Source

pub fn reachability(&self) -> Reachability

Source

pub fn external_addresses(&self) -> Vec<Multiaddr>

Addresses advertised to peers: AutoNAT-confirmed or announced.

Source

pub fn relays(&self) -> Vec<PeerId>

Relays holding an active reservation for this node.

Source

pub fn reserved_by_others(&self) -> Vec<PeerId>

Peers holding an active reservation on this node’s relay server.

Source

pub fn circuit_addresses(&self) -> Vec<Multiaddr>

This node’s /p2p-circuit listen addresses through its relays.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more