addrmanager

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 11 Imported by: 0

README

#Address Manager

Manage connected peer information and storage by interval. When node is started, it look for in data file and load old peer info to connect

Documentation

Index

Constants

View Source
const (
	UnexpectedError = iota
	StopError
	CreateDataFileError
	EncodeDataFileError
	OpenDataFileError
	DecodeDataFileError
	WrongVersionError
)

Variables

View Source
var ErrCodeMessage = map[int]struct {
	Code    int
	Message string
}{
	UnexpectedError:     {-1, "Unexpected error"},
	StopError:           {-2, "Address manager is already in the process of shutting down"},
	CreateDataFileError: {-3, "Error opening file"},
	EncodeDataFileError: {-4, "Failed to encode file"},
	OpenDataFileError:   {-5, "Error opening file"},
	DecodeDataFileError: {-6, "Error to decode file"},
	WrongVersionError:   {-7, "Unknown Version in serialized addrmanager"},
}

Global instant to use

Functions

This section is empty.

Types

type AddrManager

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

func NewAddrManager

func NewAddrManager(dataDir string, key common.Hash) *AddrManager

NewAddrManager - init a AddrManager object, set config and return pointer to object

func (*AddrManager) AddressCache

func (addrManager *AddrManager) AddressCache() []*peer.Peer

AddressCache returns the current address cache. It must be treated as read-only (but since it is a copy now, this is not as dangerous).

func (*AddrManager) Good

func (addrManager *AddrManager) Good(addr *peer.Peer)

Good marks the given address as good. To be called after a successful connection and Version exchange. If the address is unknown to the address manager it will be ignored.

func (*AddrManager) Start

func (addrManager *AddrManager) Start()

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

func (*AddrManager) Stop

func (addrManager *AddrManager) Stop() error

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

type AddrManagerError

type AddrManagerError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

func NewAddrManagerError

func NewAddrManagerError(key int, err error) *AddrManagerError

func (AddrManagerError) Error

func (e AddrManagerError) Error() string

type AddrManagerLogger

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

func (*AddrManagerLogger) Init

func (addrManagerLogger *AddrManagerLogger) Init(inst common.Logger)

Jump to

Keyboard shortcuts

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