Struct PeerRecord
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
§Cross-Implementation Compatibility
This implementation provides two formats:
- Legacy format (default methods): Compatible with existing Rust libp2p deployments.
- Standard format (
*_interopmethods): Compatible with Go and JavaScript implementations.
Use the *_interop variants (e.g., PeerRecord::new_interop,
PeerRecord::from_signed_envelope_interop) when you need to exchange peer records with
non-Rust libp2p implementations.
Implementations§
§impl PeerRecord
impl PeerRecord
pub fn from_signed_envelope(
envelope: SignedEnvelope,
) -> Result<PeerRecord, FromEnvelopeError>
pub fn from_signed_envelope( envelope: SignedEnvelope, ) -> Result<PeerRecord, FromEnvelopeError>
Attempt to re-construct a PeerRecord from a SignedEnvelope using legacy format.
Uses the legacy routing-state-record format for backward compatibility with existing Rust libp2p deployments.
If this function succeeds, the SignedEnvelope contained a peer record with a valid
signature and can hence be considered authenticated.
For cross-implementation compatibility with Go/JS libp2p, use
Self::from_signed_envelope_interop.
pub fn from_signed_envelope_interop(
envelope: SignedEnvelope,
) -> Result<PeerRecord, FromEnvelopeError>
pub fn from_signed_envelope_interop( envelope: SignedEnvelope, ) -> Result<PeerRecord, FromEnvelopeError>
Attempt to re-construct a PeerRecord from a SignedEnvelope using standard interop
format.
Uses the standard libp2p-peer-record format for cross-implementation compatibility with Go and JavaScript libp2p implementations.
If this function succeeds, the SignedEnvelope contained a peer record with a valid
signature and can hence be considered authenticated.
pub fn new(
key: &Keypair,
addresses: Vec<Multiaddr>,
) -> Result<PeerRecord, SigningError>
pub fn new( key: &Keypair, addresses: Vec<Multiaddr>, ) -> Result<PeerRecord, SigningError>
Construct a new PeerRecord by authenticating the provided addresses with the given key
using legacy format.
Uses the legacy routing-state-record format for backward compatibility with existing Rust libp2p deployments.
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.
For cross-implementation compatibility with Go/JS libp2p, use Self::new_interop.
pub fn new_interop(
key: &Keypair,
addresses: Vec<Multiaddr>,
) -> Result<PeerRecord, SigningError>
pub fn new_interop( key: &Keypair, addresses: Vec<Multiaddr>, ) -> Result<PeerRecord, SigningError>
Construct a new PeerRecord by authenticating the provided addresses with the given key
using standard interop format.
Uses the standard libp2p-peer-record format for cross-implementation compatibility with Go and JavaScript libp2p implementations.
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§
§impl Clone for PeerRecord
impl Clone for PeerRecord
§fn clone(&self) -> PeerRecord
fn clone(&self) -> PeerRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for PeerRecord
impl Debug for PeerRecord
impl Eq for PeerRecord
§impl PartialEq for PeerRecord
impl PartialEq for PeerRecord
impl StructuralPartialEq for PeerRecord
Auto Trait Implementations§
impl Forget for PeerRecord
impl Freeze for PeerRecord
impl Move for PeerRecord
impl RefUnwindSafe for PeerRecord
impl Send for PeerRecord
impl Sync for PeerRecord
impl Unpin for PeerRecord
impl UnsafeUnpin for PeerRecord
impl UnwindSafe for PeerRecord
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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