peer

package
v0.0.0-...-ce94876 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: MIT, MIT Imports: 6 Imported by: 0

README

go-libp2p-peer

standard-readme compliant GoDoc Coverage Status Build Status

PKI based identities for use in go-libp2p

Install

TODO

Usage

TODO

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT

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 (
	// ErrEmptyPeerID is an error for empty peer ID.
	ErrEmptyPeerID = errors.New("empty peer ID")
	// ErrNoPublickKey is an error for peer IDs that don't embed public keys
	ErrNoPublicKey = errors.New("public key is not embedded in peer ID")
)

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

ID is a libp2p peer identity.

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 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) ExtractPublicKey

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

ExtractPublicKey attempts to extract the public key from an ID

This method returns ErrNoPublicKey if the peer ID looks valid but it can't extract the public key.

func (ID) Loggable

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

Loggable returns a pretty peerID string in loggable JSON format

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.

func (ID) Validate

func (id ID) Validate() error

Validate check if ID is empty or not

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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