peerexchange

package
v0.2.15-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BootNodeTag is the tag used to identify boot nodes in connectionManager.
	BootNodeTag = "bootnode"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Bootnodes            []string
	DataDir              string
	CheckInterval        time.Duration // Interval to check for dead|alive peers in the book.
	CheckTimeout         time.Duration // Timeout to connect while node check for dead|alive peers in the book.
	CheckPeersNumber     int           // Number of peers to check for dead|alive peers in the book.
	CheckPeersUsedBefore time.Duration // Time to wait before checking for dead|alive peers in the book.
}

Config for Discovery.

type Discovery

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

Discovery is struct that holds the protocol components, the protocol definition, the addr book data structure and more.

func New

func New(logger log.Log, h host.Host, config Config) (*Discovery, error)

New creates a Discovery instance.

func (*Discovery) Bootstrap

func (d *Discovery) Bootstrap(ctx context.Context) error

Bootstrap runs a refresh and tries to get a minimum number of nodes in the addrBook.

func (*Discovery) CheckBook

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

CheckBook periodically checks the book for dead|alive peers.

func (*Discovery) CheckPeers

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

CheckPeers periodically checks the book for dead|alive peers.

func (*Discovery) ExternalPort

func (d *Discovery) ExternalPort() uint16

ExternalPort returns currently configured external port.

func (*Discovery) GetAddresses

func (d *Discovery) GetAddresses() []*addressbook.AddrInfo

GetAddresses returns all addresses of the node.

func (*Discovery) GetRandomPeers

func (d *Discovery) GetRandomPeers(n int) []*addressbook.AddrInfo

GetRandomPeers get random N peers from provided peers list. peer should satisfy the following conditions: - peer is not a bootnode - peer is not a connected one - peer was attempted to connect X time in ago (defined in config).

func (*Discovery) Stop

func (d *Discovery) Stop()

Stop stops the discovery service.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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