Trait libp2p_core::topology::Topology
source · pub trait Topology {
fn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr>;
fn add_local_external_addrs<TIter>(&mut self, addrs: TIter)
where
TIter: Iterator<Item = Multiaddr>;
fn local_peer_id(&self) -> &PeerId;
fn local_public_key(&self) -> &PublicKey;
}
Expand description
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
sourcefn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr>
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.
sourcefn add_local_external_addrs<TIter>(&mut self, addrs: TIter)where
TIter: Iterator<Item = Multiaddr>,
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 thePeerId
of the local node.
sourcefn local_peer_id(&self) -> &PeerId
fn local_peer_id(&self) -> &PeerId
Returns the PeerId
of the local node.
sourcefn local_public_key(&self) -> &PublicKey
fn local_public_key(&self) -> &PublicKey
Returns the public key of the local node.