discovery

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

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

Discovery combines advertise and discover services and allows to store discovered nodes.

func NewDiscovery

func NewDiscovery(
	h host.Host,
	d discovery.Discovery,
	peersLimit uint,
	discInterval,
	advertiseInterval time.Duration,
) *Discovery

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.

func (*Discovery) Peers added in v0.5.0

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

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

func (*Discovery) Start added in v0.7.0

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

func (*Discovery) Stop added in v0.7.0

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

func (*Discovery) WithOnPeersUpdate added in v0.6.3

func (d *Discovery) WithOnPeersUpdate(f OnUpdatedPeers)

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

type OnUpdatedPeers added in v0.6.3

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

Jump to

Keyboard shortcuts

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