[][src]Trait libp2p_core::topology::Topology

pub trait Topology {
    fn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr>;
fn local_peer_id(&self) -> &PeerId;
fn local_public_key(&self) -> &PublicKey;
fn add_local_external_addrs<TIter>(&mut self, addrs: TIter)
    where
        TIter: Iterator<Item = Multiaddr>
; fn set_connected(&mut self, _peer_id: &PeerId, _addr: &ConnectedPoint) { ... }
fn set_disconnected(
        &mut self,
        _peer_id: &PeerId,
        _addr: &ConnectedPoint,
        _reason: DisconnectReason
    ) { ... }
fn set_unreachable(&mut self, _addr: &Multiaddr) { ... } }

Storage for the network topology.

The topology should also store information about the local node, including its public key, its PeerId, and the addresses it's advertising.

Required methods

fn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr>

Returns the addresses to try use to reach the given peer.

Note: Keep in mind that peer can be the local node.

fn local_peer_id(&self) -> &PeerId

Returns the PeerId of the local node.

fn local_public_key(&self) -> &PublicKey

Returns the public key of the local node.

fn add_local_external_addrs<TIter>(&mut self, addrs: TIter) where
    TIter: Iterator<Item = Multiaddr>, 

Adds an address that other nodes can use to connect to our local node.

Note: Should later be returned when calling addresses_of_peer() with the PeerId of the local node.

Loading content...

Provided methods

fn set_connected(&mut self, _peer_id: &PeerId, _addr: &ConnectedPoint)

Indicates to the topology that we have successfully connected to the given address with the given PeerId.

fn set_disconnected(
    &mut self,
    _peer_id: &PeerId,
    _addr: &ConnectedPoint,
    _reason: DisconnectReason
)

Indicates to the topology that we have been disconnected from the given address with the given PeerId.

fn set_unreachable(&mut self, _addr: &Multiaddr)

Indicates to the topology that we have failed to reach the given address.

Loading content...

Implementors

impl Topology for MemoryTopology
[src]

fn set_connected(&mut self, _peer_id: &PeerId, _addr: &ConnectedPoint)
[src]

fn set_disconnected(
    &mut self,
    _peer_id: &PeerId,
    _addr: &ConnectedPoint,
    _reason: DisconnectReason
)
[src]

fn set_unreachable(&mut self, _addr: &Multiaddr)
[src]

Loading content...