libp2p/peerid

Search:
Group by:
Source   Edit  

This module implementes API for libp2p peer.Serialization/Deserialization helpers

Types

PeerId = object
  data*: seq[byte]
Source   Edit  

Procs

func `$`(pid: PeerId): string {....raises: [], public, ...tags: [], forbids: [].}
Return base58 encoded pid representation. Source   Edit  
func cmp(a, b: PeerId): int {....raises: [], public, ...tags: [], forbids: [].}
Compares two peer ids a and b. Returns:

0 iff a == b
< 0 iff a < b

0 iff a > b


Source   Edit  
func extractPublicKey(pid: PeerId; pubkey: var PublicKey): bool {....raises: [],
    public, ...tags: [RootEffect], forbids: [].}

Returns true if public key was successfully decoded from PeerId pidand stored to pubkey.

Returns false otherwise.

Source   Edit  
func getField(pb: ProtoBuffer; field: int; pid: var PeerId): ProtoResult[bool] {.
    inline, ...raises: [], public, ...tags: [], forbids: [].}
Read PeerId from ProtoBuf's message and validate it Source   Edit  
func hasPublicKey(pid: PeerId): bool {....raises: [], public, ...tags: [], forbids: [].}
Returns true if pid is small enough to hold public key inside. Source   Edit  
func hex(pid: PeerId): string {....raises: [], public, ...tags: [], forbids: [].}
Returns hexadecimal string representation of pid. Source   Edit  
func init(pid: var PeerId; data: openArray[byte]): bool {....raises: [], public,
    ...tags: [], forbids: [].}

Initialize peer id from raw binary representation data.

Returns true if peer was successfully initialiazed.

Source   Edit  
func init(pid: var PeerId; data: string): bool {....raises: [], public, ...tags: [],
    forbids: [].}

Initialize peer id from base58 encoded string representation.

Returns true if peer was successfully initialiazed.

Source   Edit  
func init(t: typedesc[PeerId]; data: openArray[byte]): Result[PeerId, cstring] {.
    ...raises: [], public.}
Create new peer id from raw binary representation data. Source   Edit  
func init(t: typedesc[PeerId]; data: string): Result[PeerId, cstring] {.
    ...raises: [], public.}
Create new peer id from base58 encoded string representation data. Source   Edit  
func init(t: typedesc[PeerId]; pubkey: PublicKey): Result[PeerId, cstring] {.
    ...raises: [], public.}
Create new peer id from public key pubkey. Source   Edit  
func init(t: typedesc[PeerId]; seckey: PrivateKey): Result[PeerId, cstring] {.
    ...raises: [], public.}
Create new peer id from private key seckey. Source   Edit  
func match(pid: PeerId; pubkey: PublicKey): bool {....raises: [], public,
    ...tags: [RootEffect], forbids: [].}
Returns true if pid matches public key pubkey. Source   Edit  
func match(pid: PeerId; seckey: PrivateKey): bool {....raises: [], public,
    ...tags: [RootEffect], forbids: [].}
Returns true if pid matches private key seckey. Source   Edit  
proc random(t: typedesc[PeerId]; rng = newRng()): Result[PeerId, cstring] {.
    ...raises: [], public.}
Create new peer id with random public key. Source   Edit  
func shortLog(pid: PeerId): string {....raises: [], public, ...tags: [], forbids: [].}
Returns compact string representation of pid. Source   Edit  
func toBytes(pid: PeerId; data: var openArray[byte]): int {....raises: [], public,
    ...tags: [], forbids: [].}

Store PeerId pid to array of bytes data.

Returns number of bytes needed to store pid.

Source   Edit  
func validate(pid: PeerId): bool {....raises: [], public, ...tags: [], forbids: [].}
Validate check if pid is empty or not. Source   Edit  
func write(pb: var ProtoBuffer; field: int; pid: PeerId) {....raises: [], public,
    ...tags: [], forbids: [].}
Write PeerId value peerid to object pb using ProtoBuf's encoding. Source   Edit  
func write(vb: var VBuffer; pid: PeerId) {....raises: [], public, ...tags: [],
    forbids: [].}
Write PeerId value peerid to buffer vb. Source   Edit  

Templates

template `<`(a, b: PeerId): bool
Source   Edit  
template `<=`(a, b: PeerId): bool
Source   Edit  
template `==`(a, b: PeerId): bool
Source   Edit  
template `>`(a, b: PeerId): bool
Source   Edit  
template `>=`(a, b: PeerId): bool
Source   Edit  
template formatItIMPL(it: PeerId): auto
Source   Edit  
template getBytes(pid: PeerId): seq[byte]
Return PeerId pid as array of bytes. Source   Edit  
template hash(pid: PeerId): Hash
Source   Edit  
template len(pid: PeerId): int
Returns length of pid binary representation. Source   Edit