peer

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PeerRequestType = "nimona.io/discovery/peer.request"
)
View Source
const (
	PeerType = "nimona.io/discovery/peer"
)

Variables

View Source
var (
	// ErrMissingKey when a key is not passed
	ErrMissingKey = errors.New("missing key")
	// ErrECDSAPrivateKeyRequired when a key is not an ECDSA key
	ErrECDSAPrivateKeyRequired = errors.New(
		"network currently requires an ecdsa private key")
)
View Source
var (
	// ErrNotFound is returned wheh a requqested item in the collection does
	// not exist
	ErrNotFound = errors.New("peer not found")
)

Functions

This section is empty.

Types

type Addresses

type Addresses []string

type LocalPeer

type LocalPeer struct {
	// contains filtered or unexported fields
}

func NewLocalPeer

func NewLocalPeer(
	hostname string,
	key *crypto.PrivateKey,
) (*LocalPeer, error)

func (*LocalPeer) AddAddress

func (p *LocalPeer) AddAddress(protocol string, addrs []string)

func (*LocalPeer) AddContentHash

func (p *LocalPeer) AddContentHash(hashes ...string)

AddContentHash that should be published with the peer info

func (*LocalPeer) AddIdentityKey

func (p *LocalPeer) AddIdentityKey(identityKey *crypto.PrivateKey) error

func (*LocalPeer) GetAddress

func (p *LocalPeer) GetAddress() string

func (*LocalPeer) GetAddresses

func (p *LocalPeer) GetAddresses() []string

func (*LocalPeer) GetContentHashes

func (p *LocalPeer) GetContentHashes() []string

func (*LocalPeer) GetFingerprint

func (p *LocalPeer) GetFingerprint() crypto.Fingerprint

func (*LocalPeer) GetHostname

func (p *LocalPeer) GetHostname() string

func (*LocalPeer) GetPeerKey

func (p *LocalPeer) GetPeerKey() *crypto.PrivateKey

func (*LocalPeer) GetSignedPeer

func (p *LocalPeer) GetSignedPeer() *Peer

GetSignedPeer returns the local peer info

func (*LocalPeer) OnAddressesUpdated

func (p *LocalPeer) OnAddressesUpdated(h OnAddressesUpdated)

func (*LocalPeer) OnContentHashesUpdated

func (p *LocalPeer) OnContentHashesUpdated(h OnContentHashesUpdated)

func (*LocalPeer) RemoveContentHash

func (p *LocalPeer) RemoveContentHash(hashes ...string)

RemoveContentHash from the peer info

type OnAddressesUpdated

type OnAddressesUpdated func([]string)

type OnContentHashesUpdated

type OnContentHashesUpdated func([]string)

type Peer

type Peer struct {
	Addresses    []string          `json:"addresses:as"`
	ContentTypes []string          `json:"contentTypes:as"`
	Signature    *crypto.Signature `json:"@signature:o"`
}

Peer holds the information exchange needs to connect to a remote peer

func (*Peer) Address

func (pi *Peer) Address() string

Address of the peer

func (Peer) Bloom

func (pi Peer) Bloom() []int

func (*Peer) Fingerprint

func (pi *Peer) Fingerprint() crypto.Fingerprint

Fingerprint of signer

func (*Peer) FromObject

func (s *Peer) FromObject(o object.Object) error

FromObject populates the struct from a f12n object

func (Peer) GetType

func (s Peer) GetType() string

GetType returns the object's type

func (Peer) ToObject

func (s Peer) ToObject() object.Object

ToObject returns a f12n object

type PeerCollection

type PeerCollection struct {
	// contains filtered or unexported fields
}

PeerCollection allows concurrent access to peers

func (*PeerCollection) All

func (c *PeerCollection) All() ([]*Peer, error)

All returns all items in the collection

func (*PeerCollection) Get

func (c *PeerCollection) Get(fingerprint string) (*Peer, error)

Get retuns a single item from the collection given its id

func (*PeerCollection) Put

func (c *PeerCollection) Put(peer *Peer) error

Put adds or overwrites an item in the collection

type PeerRequest

type PeerRequest struct {
	Keys         []crypto.Fingerprint `json:"keys:ao"`
	ContentTypes []string             `json:"contentTypes:as"`
}

PeerRequest is a request for a peer info

func (*PeerRequest) FromObject

func (s *PeerRequest) FromObject(o object.Object) error

FromObject populates the struct from a f12n object

func (PeerRequest) GetType

func (s PeerRequest) GetType() string

GetType returns the object's type

func (PeerRequest) ToObject

func (s PeerRequest) ToObject() object.Object

ToObject returns a f12n object

type StringAddressesSyncMap

type StringAddressesSyncMap struct {
	// contains filtered or unexported fields
}

StringAddressesSyncMap -

func NewStringAddressesSyncMap

func NewStringAddressesSyncMap() *StringAddressesSyncMap

NewStringAddressesSyncMap constructs a new SyncMap

func (*StringAddressesSyncMap) Delete

func (m *StringAddressesSyncMap) Delete(k string)

Delete -

func (*StringAddressesSyncMap) Get

Get -

func (*StringAddressesSyncMap) Put

func (m *StringAddressesSyncMap) Put(k string, v *Addresses)

Put -

func (*StringAddressesSyncMap) Range

func (m *StringAddressesSyncMap) Range(i func(k string, v *Addresses) bool)

Range -

type StringSyncList

type StringSyncList struct {
	// contains filtered or unexported fields
}

StringSyncList -

func NewStringValueTypeSyncMap

func NewStringValueTypeSyncMap() *StringSyncList

NewStringValueTypeSyncMap constructs a new SyncMap

func (*StringSyncList) Delete

func (m *StringSyncList) Delete(k string)

Delete -

func (*StringSyncList) Exists

func (m *StringSyncList) Exists(k string) bool

Exists -

func (*StringSyncList) Put

func (m *StringSyncList) Put(k string)

Put -

func (*StringSyncList) Range

func (m *StringSyncList) Range(i func(k string) bool)

Range -

Jump to

Keyboard shortcuts

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