peer

package
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

package peer implements an object used to represent peers in the ipfs network.

Index

Constants

This section is empty.

Variables

View Source
var CodePrefixErr = errors.New("unexpected code prefix")
View Source
var MultihashCodecErr = errors.New("unexpected multihash codec")
View Source
var MultihashDecodeErr = errors.New("unable to decode multihash")
View Source
var MultihashLengthErr = errors.New("unexpected multihash length")

Functions

func IDB58Encode

func IDB58Encode(id ID) string

IDB58Encode returns b58-encoded string

func IDHexEncode

func IDHexEncode(id ID) string

IDHexEncode returns hex-encoded string

Types

type ID

type ID string

func IDB58Decode

func IDB58Decode(s string) (ID, error)

IDB58Decode returns a b58-decoded Peer

func IDFromBytes

func IDFromBytes(b []byte) (ID, error)

IDFromBytes cast a string to ID type, and validate the id to make sure it is a multihash.

func IDFromEd25519PublicKey

func IDFromEd25519PublicKey(pk ic.PubKey) (ID, error)

IDFromEd25519PublicKey returns the Peer ID corresponding to Id25519 pk

func IDFromPrivateKey

func IDFromPrivateKey(sk ic.PrivKey) (ID, error)

IDFromPrivateKey returns the Peer ID corresponding to sk

func IDFromPublicKey

func IDFromPublicKey(pk ic.PubKey) (ID, error)

IDFromPublicKey returns the Peer ID corresponding to pk

func IDFromString

func IDFromString(s string) (ID, error)

IDFromString cast a string to ID type, and validate the id to make sure it is a multihash.

func IDHexDecode

func IDHexDecode(s string) (ID, error)

IDHexDecode returns a hex-decoded Peer

func (ID) ExtractEd25519PublicKey

func (id ID) ExtractEd25519PublicKey() (ic.PubKey, error)

func (ID) ExtractPublicKey

func (id ID) ExtractPublicKey() ic.PubKey

ExtractPublicKey attempts to extract the public key from an ID

func (ID) Loggable

func (id ID) Loggable() map[string]interface{}

func (ID) MatchesPrivateKey

func (id ID) MatchesPrivateKey(sk ic.PrivKey) bool

MatchesPrivateKey tests whether this ID was derived from sk

func (ID) MatchesPublicKey

func (id ID) MatchesPublicKey(pk ic.PubKey) bool

MatchesPublicKey tests whether this ID was derived from pk

func (ID) Pretty

func (id ID) Pretty() string

Pretty returns a b58-encoded string of the ID

func (ID) String

func (id ID) String() string

String prints out the peer.

TODO(brian): ensure correctness at ID generation and enforce this by only exposing functions that generate IDs safely. Then any peer.ID type found in the codebase is known to be correct.

type IDSlice

type IDSlice []ID

IDSlice for sorting peers

func (IDSlice) Len

func (es IDSlice) Len() int

func (IDSlice) Less

func (es IDSlice) Less(i, j int) bool

func (IDSlice) Swap

func (es IDSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL