discovery

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package discovery provides peer discovery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	P2P        *p2p.Config
	DBPath     string
	ListenAddr net.UDPAddr
}

func DefaultConfig

func DefaultConfig(p2pConfig *p2p.Config) *Config

DefaultConfig constructs discovery config using viper.

type Node

type Node struct {
	Config     *Config
	Peers      *Peers
	PrivateKey *ecdsa.PrivateKey
	// contains filtered or unexported fields
}

Node participates in the discv5 network.

func NewNode

func NewNode(config *Config, peers *Peers, key *ecdsa.PrivateKey) *Node

func (*Node) Close

func (n *Node) Close()

func (*Node) Listen

func (n *Node) Listen() (err error)

Listen starts up the discv5 UDP listener and node logic.

type Peers

type Peers struct {
	DB    *enode.DB
	Local *enode.LocalNode
}

Peers keeps track about the node's own ENR and all other peers' ENRs.

func NewPeerDB

func NewPeerDB(config *Config, p2pConfig *p2p.Config, key *ecdsa.PrivateKey) (*Peers, error)

NewPeerDB opens the peer discovery database.

func (*Peers) Close

func (c *Peers) Close()

Close saves and closes the peer discovery database.

The Peers object must not be used after closing.

Jump to

Keyboard shortcuts

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