Struct sc_peerset::PeerId
pub struct PeerId { /* private fields */ }
Expand description
Identifier of a peer of the network.
The data is a CIDv0 compatible multihash of the protobuf encoded public key of the peer as specified in specs/peer-ids.
Implementations§
§impl PeerId
impl PeerId
pub fn from_public_key(key: &PublicKey) -> PeerId
pub fn from_public_key(key: &PublicKey) -> PeerId
Builds a PeerId
from a public key.
pub fn from_bytes(data: &[u8]) -> Result<PeerId, Error>
pub fn from_bytes(data: &[u8]) -> Result<PeerId, Error>
Parses a PeerId
from bytes.
pub fn from_multihash(multihash: Multihash<64>) -> Result<PeerId, Multihash<64>>
pub fn from_multihash(multihash: Multihash<64>) -> Result<PeerId, Multihash<64>>
Tries to turn a Multihash
into a PeerId
.
If the multihash does not use a valid hashing algorithm for peer IDs,
or the hash value does not satisfy the constraints for a hashed
peer ID, it is returned as an Err
.
pub fn try_from_multiaddr(address: &Multiaddr) -> Option<PeerId>
pub fn try_from_multiaddr(address: &Multiaddr) -> Option<PeerId>
pub fn random() -> PeerId
pub fn random() -> PeerId
Generates a random peer ID from a cryptographically secure PRNG.
This is useful for randomly walking on a DHT, or for testing purposes.
pub fn is_public_key(&self, public_key: &PublicKey) -> Option<bool>
pub fn is_public_key(&self, public_key: &PublicKey) -> Option<bool>
Checks whether the public key passed as parameter matches the public key of this PeerId
.
Returns None
if this PeerId
s hash algorithm is not supported when encoding the
given public key, otherwise Some
boolean as the result of an equality check.
Trait Implementations§
§impl Ord for PeerId
impl Ord for PeerId
§impl PartialOrd<PeerId> for PeerId
impl PartialOrd<PeerId> for PeerId
§fn partial_cmp(&self, other: &PeerId) -> Option<Ordering>
fn partial_cmp(&self, other: &PeerId) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for PeerId
impl Eq for PeerId
impl StructuralEq for PeerId
impl StructuralPartialEq for PeerId
Auto Trait Implementations§
impl RefUnwindSafe for PeerId
impl Send for PeerId
impl Sync for PeerId
impl Unpin for PeerId
impl UnwindSafe for PeerId
Blanket Implementations§
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read more§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.