pex

package
v0.0.0-...-15e8d78 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: GPL-3.0, GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddrBook

func NewAddrBook(filePath string, routabilityStrict bool) *addrBook

NewAddrBook creates a new address book. Use Start to begin processing asynchronous address updates.

Types

type AddrBook

type AddrBook interface {
	help.Service

	// Add our own addresses so we don't later add ourselves
	AddOurAddress(*tp2p.NetAddress)
	// Check if it is our address
	OurAddress(*tp2p.NetAddress) bool

	AddPrivateIDs([]string)

	// Add and remove an address
	AddAddress(addr *tp2p.NetAddress, src *tp2p.NetAddress) error
	RemoveAddress(*tp2p.NetAddress)

	// Check if the address is in the book
	HasAddress(*tp2p.NetAddress) bool

	// Do we need more peers?
	NeedMoreAddrs() bool
	// Is Address Book Empty? Answer should not depend on being in your own
	// address book, or private peers
	Empty() bool

	// Pick an address to dial
	PickAddress(biasTowardsNewAddrs int) *tp2p.NetAddress

	// Mark address
	MarkGood(*tp2p.NetAddress)
	MarkAttempt(*tp2p.NetAddress)
	MarkBad(*tp2p.NetAddress)

	IsGood(*tp2p.NetAddress) bool

	// Send a selection of addresses to peers
	GetSelection() []*tp2p.NetAddress
	// Send a selection of addresses with bias
	GetSelectionWithBias(biasTowardsNewAddrs int) []*tp2p.NetAddress

	// TODO: remove
	ListOfKnownAddresses() []*knownAddress

	// Persist to disk
	Save()
}

AddrBook is an address book used for tracking peers so we can gossip about them to others and select peers to dial. TODO: break this up?

type ErrAddrBookNilAddr

type ErrAddrBookNilAddr struct {
	Addr *tp2p.NetAddress
	Src  *tp2p.NetAddress
}

func (ErrAddrBookNilAddr) Error

func (err ErrAddrBookNilAddr) Error() string

type ErrAddrBookNonRoutable

type ErrAddrBookNonRoutable struct {
	Addr *tp2p.NetAddress
}

func (ErrAddrBookNonRoutable) Error

func (err ErrAddrBookNonRoutable) Error() string

type ErrAddrBookPrivate

type ErrAddrBookPrivate struct {
	Addr *tp2p.NetAddress
}

func (ErrAddrBookPrivate) Error

func (err ErrAddrBookPrivate) Error() string

type ErrAddrBookPrivateSrc

type ErrAddrBookPrivateSrc struct {
	Src *tp2p.NetAddress
}

func (ErrAddrBookPrivateSrc) Error

func (err ErrAddrBookPrivateSrc) Error() string

type ErrAddrBookSelf

type ErrAddrBookSelf struct {
	Addr *tp2p.NetAddress
}

func (ErrAddrBookSelf) Error

func (err ErrAddrBookSelf) Error() string

Jump to

Keyboard shortcuts

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