peerexchange

package
v0.2.22-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 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
	AdvertiseAddress     string             // Address to advertise to a peers.
	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.
	PeerExchange         PeerExchangeConfig // Configuration for Peer Exchange protocol
}

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) AdvertisedAddress

func (d *Discovery) AdvertisedAddress() ma.Multiaddr

AdvertisedAddress returns advertised address.

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) 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.

type PeerExchangeConfig

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

Peer Exchange protocol configuration.

func DefaultPeerExchangeConfig

func DefaultPeerExchangeConfig() PeerExchangeConfig

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