addrmgr

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger elalog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using elalog.

Types

type AddrManager

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

AddrManager provides a concurrency safe address manager for caching potential peers on the network.

func New

func New(dataDir string) *AddrManager

New returns a new address manager. Use Start to begin processing asynchronous address updates.

func (*AddrManager) AddAddress

func (a *AddrManager) AddAddress(pid [33]byte, addr net.Addr)

AddAddress adds a new address to the address manager. It enforces a max number of addresses and silently ignores duplicate addresses. It is safe for concurrent access.

func (*AddrManager) DeserializeNetAddress

func (a *AddrManager) DeserializeNetAddress(addr string) (net.Addr, error)

DeserializeNetAddress converts a given address string to a *p2p.NetAddress

func (*AddrManager) GetAddress

func (a *AddrManager) GetAddress(pid [33]byte) net.Addr

GetAddress returns the network address according to the given PID and Encode.

func (*AddrManager) HostToNetAddress

func (a *AddrManager) HostToNetAddress(host string, port uint16, services uint64) (net.Addr, error)

HostToNetAddress returns a netaddress given a host address. If the address is a Tor .onion address this will be taken care of. Else if the host is not an IP address it will be resolved (via Tor if required).

func (*AddrManager) Start

func (a *AddrManager) Start()

Start begins the core address handler which manages a pool of known addresses, timeouts, and interval based writes.

func (*AddrManager) Stop

func (a *AddrManager) Stop()

Stop gracefully shuts down the address manager by stopping the main handler.

Jump to

Keyboard shortcuts

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