discovery

package
v0.17.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDHT

func NewDHT(
	ctx context.Context,
	prefix string,
	bootsrappers []peer.AddrInfo,
	host host.Host,
	dataStore datastore.Batching,
	mode dht.ModeOpt,
) (*dht.IpfsDHT, error)

PeerRouting provides constructor for PeerRouting over DHT. Basically, this provides a way to discover peer addresses by respecting public keys.

Types

type Discovery

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

Discovery combines advertise and discover services and allows to store discovered nodes. TODO: The code here gets horribly hairy, so we should refactor this at some point

func NewDiscovery

func NewDiscovery(
	params *Parameters,
	h host.Host,
	d discovery.Discovery,
	prefix string,
	tag string,
	opts ...Option,
) (*Discovery, error)

NewDiscovery constructs a new discovery.

func (*Discovery) Advertise

func (d *Discovery) Advertise(ctx context.Context)

Advertise is a utility function that persistently advertises a service through an Advertiser. TODO: Start advertising only after the reachability is confirmed by AutoNAT

func (*Discovery) Discard

func (d *Discovery) Discard(id peer.ID) bool

Discard removes the peer from the peer set and rediscovers more if soft peer limit is not reached. Reports whether peer was removed with bool.

func (*Discovery) Peers

func (d *Discovery) Peers(ctx context.Context) ([]peer.ID, error)

Peers provides a list of discovered peers in the given topic. If Discovery hasn't found any peers, it blocks until at least one peer is found.

func (*Discovery) Start

func (d *Discovery) Start(context.Context) error

func (*Discovery) Stop

func (d *Discovery) Stop(context.Context) error

func (*Discovery) WithMetrics

func (d *Discovery) WithMetrics() error

WithMetrics turns on metric collection in discoery.

type OnUpdatedPeers

type OnUpdatedPeers func(peerID peer.ID, isAdded bool)

type Option

type Option func(*options)

Option is a function that configures Discovery Parameters

func WithAdvertise

func WithAdvertise() Option

func WithOnPeersUpdate

func WithOnPeersUpdate(f OnUpdatedPeers) Option

WithOnPeersUpdate chains OnPeersUpdate callbacks on every update of discovered peers list.

type Parameters

type Parameters struct {
	// PeersLimit defines the soft limit of FNs to connect to via discovery.
	// Set 0 to disable.
	PeersLimit uint
	// AdvertiseInterval is a interval between advertising sessions.
	// NOTE: only full and bridge can advertise themselves.
	AdvertiseInterval time.Duration
}

Parameters is the set of Parameters that must be configured for the Discovery module

func DefaultParameters

func DefaultParameters() *Parameters

DefaultParameters returns the default Parameters' configuration values for the Discovery module

func (*Parameters) Validate

func (p *Parameters) Validate() error

Validate validates the values in Parameters

Jump to

Keyboard shortcuts

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