discovery

package
v0.0.0-...-97b9ebb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package discovery provides discovery protocol interfaces and its implementations. The main API are:

  • `Discovery` - provides all API for discovery protocol, such as resolving peer addresses by locator IDs. It keeps local peers table in sync, it checks the local table before query remote providers, and update it on success lookup. It can be created using `NewDiscovery` factory function.
  • `Provider` - remote discovery provider API, It performs query lookup operation in any remote kind of storage, E.g. it may have implementations for database, etcd, DHT, etc.
  • `ErrNotFound` - error returned when peer was not found. The error can be checked with `errors.As(err, &notFound)`.
  • `ErrFailedToResolve` - generic error wrapper, encapsulates more concrete errors, to get caused errors use `errors.Unwrap` or `errors.As()`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalTable

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

LocalTable is a local in memory peer table

func NewLocalTable

func NewLocalTable() *LocalTable

NewLocalTable peer table

func (*LocalTable) Lookup

func (t *LocalTable) Lookup(id mh.Multihash) (res Peer, found bool)

Lookup for peer by it's locator ID

func (*LocalTable) Update

func (t *LocalTable) Update(p Peer)

Update local table with a new peer

type Peer

type Peer struct {
	Locator *locators.Node
	Addr    ma.Multiaddr
}

Peer node

func (*Peer) GoString

func (p *Peer) GoString() string

GoString returns debug information for `%#v` format option

func (*Peer) String

func (p *Peer) String() string

type PeerTable

type PeerTable interface {
	// Update peer table with a new entry
	Update(Peer)

	// Lookup for peer by it's locator ID
	Lookup(mh.Multihash) (Peer, bool)
}

PeerTable stores addresses for known peers

Jump to

Keyboard shortcuts

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