Documentation ¶
Index ¶
- type Discovery
- func (d *Discovery) Advertise(ctx context.Context)
- func (d *Discovery) Discard(id peer.ID) bool
- func (d *Discovery) Peers(ctx context.Context) ([]peer.ID, error)
- func (d *Discovery) Start(context.Context) error
- func (d *Discovery) Stop(context.Context) error
- func (d *Discovery) WithMetrics() error
- func (d *Discovery) WithOnPeersUpdate(f OnUpdatedPeers)
- type OnUpdatedPeers
- type Option
- type Parameters
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. TODO: The code here gets horribly hairy, so we should refactor this at some point
func NewDiscovery ¶
NewDiscovery constructs a new discovery.
func (*Discovery) Advertise ¶
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 ¶
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 ¶
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) WithMetrics ¶
WithMetrics turns on metric collection in discoery.
func (*Discovery) WithOnPeersUpdate ¶
func (d *Discovery) WithOnPeersUpdate(f OnUpdatedPeers)
WithOnPeersUpdate chains OnPeersUpdate callbacks on every update of discovered peers list.
type OnUpdatedPeers ¶
type Option ¶
type Option func(*Parameters)
Option is a function that configures Discovery Parameters
func WithAdvertiseInterval ¶
WithAdvertiseInterval is a functional option that Discovery uses to set the AdvertiseInterval configuration param
func WithPeersLimit ¶
WithPeersLimit is a functional option that Discovery uses to set the PeersLimit configuration param
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. // Set -1 to disable. // 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