peer

package
v0.0.0-...-bebc87d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = ds.ErrNotFound

ErrNotFound signals a peer wasn't found. this is here to avoid having to leak the ds abstraction to clients of Peerstore, just for the error.

Functions

This section is empty.

Types

type ID

type ID mh.Multihash

ID is a byte slice representing the identity of a peer.

func DecodePrettyID

func DecodePrettyID(s string) ID

DecodePrettyID returns a b58-encoded string of the ID

func (ID) Equal

func (id ID) Equal(other ID) bool

Equal is utililty function for comparing two peer ID's

func (ID) Pretty

func (id ID) Pretty() string

Pretty returns a b58-encoded string of the ID

type Map

type Map map[u.Key]*Peer

Map maps Key (string) : *Peer (slices are not comparable).

type Peer

type Peer struct {
	ID        ID
	Addresses []*ma.Multiaddr

	PrivKey ic.PrivKey
	PubKey  ic.PubKey

	sync.RWMutex
	// contains filtered or unexported fields
}

Peer represents the identity information of an IPFS Node, including ID, and relevant Addresses.

func (*Peer) AddAddress

func (p *Peer) AddAddress(a *ma.Multiaddr)

AddAddress adds the given Multiaddr address to Peer's addresses.

func (*Peer) GetLatency

func (p *Peer) GetLatency() (out time.Duration)

GetLatency retrieves the current latency measurement.

func (*Peer) Key

func (p *Peer) Key() u.Key

Key returns the ID as a Key (string) for maps.

func (*Peer) NetAddress

func (p *Peer) NetAddress(n string) *ma.Multiaddr

NetAddress returns the first Multiaddr found for a given network.

func (*Peer) SetLatency

func (p *Peer) SetLatency(laten time.Duration)

SetLatency sets the latency measurement. TODO: Instead of just keeping a single number,

keep a running average over the last hour or so

Yep, should be EWMA or something. (-jbenet)

type Peerstore

type Peerstore interface {
	Get(ID) (*Peer, error)
	Put(*Peer) error
	Delete(ID) error
	All() (*Map, error)
}

Peerstore provides a threadsafe collection for peers.

func NewPeerstore

func NewPeerstore() Peerstore

NewPeerstore creates a threadsafe collection of peers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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