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_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.

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.

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 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.

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<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