Documentation ¶
Index ¶
- Constants
- Variables
- type Addresses
- type LocalPeer
- func (p *LocalPeer) AddAddress(protocol string, addrs []string)
- func (p *LocalPeer) AddContentHash(hashes ...string)
- func (p *LocalPeer) AddIdentityKey(identityKey *crypto.PrivateKey) error
- func (p *LocalPeer) GetAddress() string
- func (p *LocalPeer) GetAddresses() []string
- func (p *LocalPeer) GetContentHashes() []string
- func (p *LocalPeer) GetFingerprint() crypto.Fingerprint
- func (p *LocalPeer) GetHostname() string
- func (p *LocalPeer) GetPeerKey() *crypto.PrivateKey
- func (p *LocalPeer) GetSignedPeer() *Peer
- func (p *LocalPeer) OnAddressesUpdated(h OnAddressesUpdated)
- func (p *LocalPeer) OnContentHashesUpdated(h OnContentHashesUpdated)
- func (p *LocalPeer) RemoveContentHash(hashes ...string)
- type OnAddressesUpdated
- type OnContentHashesUpdated
- type Peer
- type PeerCollection
- type PeerRequest
- type StringAddressesSyncMap
- type StringSyncList
Constants ¶
const (
PeerRequestType = "nimona.io/discovery/peer.request"
)
const (
PeerType = "nimona.io/discovery/peer"
)
Variables ¶
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") )
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 LocalPeer ¶
type LocalPeer struct {
// contains filtered or unexported fields
}
func NewLocalPeer ¶
func NewLocalPeer( hostname string, key *crypto.PrivateKey, ) (*LocalPeer, error)
func (*LocalPeer) AddAddress ¶
func (*LocalPeer) AddContentHash ¶
AddContentHash that should be published with the peer info
func (*LocalPeer) AddIdentityKey ¶
func (p *LocalPeer) AddIdentityKey(identityKey *crypto.PrivateKey) error
func (*LocalPeer) GetAddress ¶
func (*LocalPeer) GetAddresses ¶
func (*LocalPeer) GetContentHashes ¶
func (*LocalPeer) GetFingerprint ¶
func (p *LocalPeer) GetFingerprint() crypto.Fingerprint
func (*LocalPeer) GetHostname ¶
func (*LocalPeer) GetPeerKey ¶
func (p *LocalPeer) GetPeerKey() *crypto.PrivateKey
func (*LocalPeer) GetSignedPeer ¶
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 ¶
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) FromObject ¶
FromObject populates the struct from 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) Get ¶
func (m *StringAddressesSyncMap) Get(k string) (*Addresses, bool)
Get -
func (*StringAddressesSyncMap) Put ¶
func (m *StringAddressesSyncMap) Put(k string, v *Addresses)
Put -
type StringSyncList ¶
type StringSyncList struct {
// contains filtered or unexported fields
}
StringSyncList -
func NewStringValueTypeSyncMap ¶
func NewStringValueTypeSyncMap() *StringSyncList
NewStringValueTypeSyncMap constructs a new SyncMap