discovery

package
v0.6.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: Apache-2.0 Imports: 12 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 core.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) EnsurePeers

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

EnsurePeers ensures we always have 'peerLimit' connected peers. It starts peer discovery every 30 seconds until peer cache reaches peersLimit. Discovery is restarted if any previously connected peers disconnect.

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.

Jump to

Keyboard shortcuts

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