Struct libp2prs_core::peerstore::PeerStore[][src]

pub struct PeerStore { /* fields omitted */ }

Implementations

impl PeerStore[src]

pub fn save_data(&self) -> Result<()>[src]

Save addr_book when closing swarm

pub fn load_data(&self) -> Result<()>[src]

Load addr_book when initializing swarm

pub fn get_peers(&self) -> Vec<PeerId>[src]

Gets all peer Ids in peer store.

pub fn pin(&self, peer_id: &PeerId)[src]

Pins the peer Id so that GC wouldn’t recycle the multiaddr of the peer.

pub fn unpin(&self, peer_id: &PeerId)[src]

Unpins the peer Id.

pub fn pinned(&self, peer_id: &PeerId) -> bool[src]

Checks if the peer is currently being pinned in peer store.

pub fn add_key(&self, peer_id: &PeerId, key: PublicKey)[src]

Adds public key by peer_id.

pub fn get_key(&self, peer_id: &PeerId) -> Option<PublicKey>[src]

Gets public key by peer_id.

pub fn add_addr(&self, peer_id: &PeerId, addr: Multiaddr, ttl: Duration)[src]

Add address to address_book by peer_id, if exists, update rtt.

pub fn add_addrs(&self, peer_id: &PeerId, addrs: Vec<Multiaddr>, ttl: Duration)[src]

Adds many new addresses if they’re not already in the Address Book.

pub fn clear_addrs(&self, peer_id: &PeerId)[src]

Removes all multiaddr of a peer from peer store.

pub fn get_addrs(&self, peer_id: &PeerId) -> Option<Vec<Multiaddr>>[src]

Retrieves the all multiaddr of a peer from the peer store.

pub fn update_addr(&self, peer_id: &PeerId, new_ttl: Duration)[src]

Updates the ttl of the multiaddr of the peer.

pub fn remove_expired_addrs(&self)[src]

Removes all expired address.

pub fn add_protocols(&self, peer_id: &PeerId, protos: Vec<String>)[src]

Adds the supported protocols of a peer to the peer store.

pub fn clear_protocols(&self, peer_id: &PeerId)[src]

Clears the protocols by peer_id

pub fn get_protocols(&self, peer_id: &PeerId) -> Option<Vec<String>>[src]

Gets the protocols by peer_id.

pub fn first_supported_protocol(
    &self,
    peer_id: &PeerId,
    protos: Vec<String>
) -> Option<String>
[src]

Get the first protocol which is matched by the given protocols.

pub fn support_protocols(
    &self,
    peer_id: &PeerId,
    protos: Vec<String>
) -> Option<Vec<String>>
[src]

Searches all protocols and return an option that matches by the given protocols.

Trait Implementations

impl Clone for PeerStore[src]

impl Default for PeerStore[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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