Struct libp2p_core::peer_record::PeerRecord
source · pub struct PeerRecord { /* private fields */ }
Expand description
Represents a peer routing record.
Peer records are designed to be distributable and carry a signature by being wrapped in a signed envelope. For more information see RFC0003 of the libp2p specifications: https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md
Implementations§
source§impl PeerRecord
impl PeerRecord
sourcepub fn from_signed_envelope(
envelope: SignedEnvelope,
) -> Result<Self, FromEnvelopeError>
pub fn from_signed_envelope( envelope: SignedEnvelope, ) -> Result<Self, FromEnvelopeError>
Attempt to re-construct a PeerRecord
from a SignedEnvelope
.
If this function succeeds, the SignedEnvelope
contained a peer record with a valid signature and can hence be considered authenticated.
sourcepub fn new(
key: &Keypair,
addresses: Vec<Multiaddr>,
) -> Result<Self, SigningError>
pub fn new( key: &Keypair, addresses: Vec<Multiaddr>, ) -> Result<Self, SigningError>
Construct a new PeerRecord
by authenticating the provided addresses with the given key.
This is the same key that is used for authenticating every libp2p connection of your application, i.e. what you use when setting up your crate::transport::Transport
.
pub fn to_signed_envelope(&self) -> SignedEnvelope
pub fn into_signed_envelope(self) -> SignedEnvelope
pub fn peer_id(&self) -> PeerId
pub fn seq(&self) -> u64
pub fn addresses(&self) -> &[Multiaddr]
Trait Implementations§
source§impl Clone for PeerRecord
impl Clone for PeerRecord
source§fn clone(&self) -> PeerRecord
fn clone(&self) -> PeerRecord
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PeerRecord
impl Debug for PeerRecord
source§impl PartialEq for PeerRecord
impl PartialEq for PeerRecord
source§fn eq(&self, other: &PeerRecord) -> bool
fn eq(&self, other: &PeerRecord) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for PeerRecord
impl StructuralPartialEq for PeerRecord
Auto Trait Implementations§
impl Freeze for PeerRecord
impl RefUnwindSafe for PeerRecord
impl Send for PeerRecord
impl Sync for PeerRecord
impl Unpin for PeerRecord
impl UnwindSafe for PeerRecord
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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