discovery

package
v0.16.4-10-g795afc28 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EthereumV5 is kademlia-based discovery from go-ethereum repository.
	EthereumV5 = "ethv5"
	// RendezvousV1 is req/rep based discovery that uses ENR for records.
	RendezvousV1 = "ethvousv1"
)

Variables

This section is empty.

Functions

func ProxyToRendezvous added in v0.13.0

func ProxyToRendezvous(original Discovery, stop chan struct{}, feed *event.Feed, opts ProxyOptions) error

ProxyToRendezvous proxies records discovered using original to rendezvous servers for specified topic.

Types

type DiscV5

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

DiscV5 is a facade for ethereum discv5 implementation.

func NewDiscV5

func NewDiscV5(prv *ecdsa.PrivateKey, laddr string, bootnodes []*discv5.Node) *DiscV5

NewDiscV5 creates instances of discovery v5 facade.

func (*DiscV5) Discover

func (d *DiscV5) Discover(topic string, period <-chan time.Duration, found chan<- *discv5.Node, lookup chan<- bool) error

Discover creates search request in v5 server. Results will be published to found channel. It will block until period is closed.

func (*DiscV5) Register

func (d *DiscV5) Register(topic string, stop chan struct{}) error

Register creates a register request in v5 server. It will block until stop is closed.

func (*DiscV5) Running

func (d *DiscV5) Running() bool

Running returns true if v5 server is started.

func (*DiscV5) Start

func (d *DiscV5) Start() error

Start creates v5 server and stores pointer to it.

func (*DiscV5) Stop

func (d *DiscV5) Stop() error

Stop closes v5 server listener and removes pointer.

type Discovery

type Discovery interface {
	Running() bool
	Start() error
	Stop() error
	Register(topic string, stop chan struct{}) error
	Discover(topic string, period <-chan time.Duration, found chan<- *discv5.Node, lookup chan<- bool) error
}

Discovery is an abstract interface for using different discovery providers.

type Multiplexer

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

Multiplexer allows to use multiple discoveries behind single Discovery interface.

func NewMultiplexer

func NewMultiplexer(discoveries []Discovery) Multiplexer

NewMultiplexer creates Multiplexer instance.

func (Multiplexer) Discover

func (m Multiplexer) Discover(topic string, period <-chan time.Duration, found chan<- *discv5.Node, lookup chan<- bool) error

Discover shares topic and channles for receiving results. And multiplexer periods that are sent to period channel.

func (Multiplexer) Register

func (m Multiplexer) Register(topic string, stop chan struct{}) error

Register passed topic and stop channel to every discovery and waits till it will return.

func (Multiplexer) Running

func (m Multiplexer) Running() (rst bool)

Running should return true if at least one discovery is running

func (Multiplexer) Start

func (m Multiplexer) Start() (err error)

Start every discovery and stop every started in case if at least one fails.

func (Multiplexer) Stop

func (m Multiplexer) Stop() (err error)

Stop every discovery.

type Proxied added in v0.13.0

type Proxied discv5.NodeID

Proxied is an Entry for ENR

func (Proxied) ENRKey added in v0.13.0

func (p Proxied) ENRKey() string

ENRKey returns unique key that is used by ENR.

type ProxyOptions added in v0.16.3

type ProxyOptions struct {
	Topic          string
	Servers        []ma.Multiaddr
	Limit          int
	LivenessWindow time.Duration
}

type Rendezvous

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

Rendezvous is an implementation of discovery interface that uses rendezvous client.

func NewRendezvous

func NewRendezvous(servers []ma.Multiaddr, identity *ecdsa.PrivateKey, node *discover.Node) (*Rendezvous, error)

func NewRendezvousWithENR added in v0.13.0

func NewRendezvousWithENR(servers []ma.Multiaddr, record enr.Record) *Rendezvous

func (*Rendezvous) Discover

func (r *Rendezvous) Discover(
	topic string, period <-chan time.Duration, found chan<- *discv5.Node, lookup chan<- bool,
) error

Discover will search for new records every time period fetched from period channel.

func (*Rendezvous) MakeRecord added in v0.15.1

func (r *Rendezvous) MakeRecord() (record enr.Record, err error)

func (*Rendezvous) Register

func (r *Rendezvous) Register(topic string, stop chan struct{}) error

Register renews registration in the specified server.

func (*Rendezvous) Running

func (r *Rendezvous) Running() bool

func (*Rendezvous) Start

func (r *Rendezvous) Start() error

Start creates client with ephemeral identity.

func (*Rendezvous) Stop

func (r *Rendezvous) Stop() error

Stop removes client reference.

Jump to

Keyboard shortcuts

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