enodes

package
v0.0.0-...-f06f5b4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressEntry

type AddressEntry struct {
	Node      *enode.Node
	Timestamp uint
}

AddressEntry is an entry for the valEnodeTable

func (*AddressEntry) DecodeRLP

func (ve *AddressEntry) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and load the AddressEntry fields from a RLP stream.

func (*AddressEntry) EncodeRLP

func (ve *AddressEntry) EncodeRLP(w io.Writer) error

EncodeRLP serializes AddressEntry into the Ethereum RLP format.

func (*AddressEntry) String

func (ve *AddressEntry) String() string

type ValEnodeEntryInfo

type ValEnodeEntryInfo struct {
	Enode     string `json:"enode"`
	Timestamp uint   `json:"timestamp"`
}

type ValidatorEnodeDB

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

ValidatorEnodeDB represents a Map that can be accessed either by address or enode

func OpenValidatorEnodeDB

func OpenValidatorEnodeDB(path string, handler ValidatorEnodeHandler) (*ValidatorEnodeDB, error)

OpenValidatorEnodeDB opens a validator enode database for storing and retrieving infos about validator enodes. If no path is given an in-memory, temporary database is constructed.

func (*ValidatorEnodeDB) Close

func (vet *ValidatorEnodeDB) Close() error

Close flushes and closes the database files.

func (*ValidatorEnodeDB) GetAddressFromNodeID

func (vet *ValidatorEnodeDB) GetAddressFromNodeID(nodeID enode.ID) (common.Address, error)

GetAddressFromNodeID will return the address for an nodeID if it's known

func (*ValidatorEnodeDB) GetAllValEnodes

func (vet *ValidatorEnodeDB) GetAllValEnodes() (map[common.Address]*AddressEntry, error)

GetAllValEnodes will return all entries in the valEnodeDB

func (*ValidatorEnodeDB) GetNodeFromAddress

func (vet *ValidatorEnodeDB) GetNodeFromAddress(address common.Address) (*enode.Node, error)

GetEnodeURLFromAddress will return the enodeURL for an address if it's known

func (*ValidatorEnodeDB) GetTimestampFromAddress

func (vet *ValidatorEnodeDB) GetTimestampFromAddress(address common.Address) (uint, error)

GetTimestampFromAddress will return the timestamp for an address if it's known

func (*ValidatorEnodeDB) PruneEntries

func (vet *ValidatorEnodeDB) PruneEntries(addressesToKeep map[common.Address]bool) error

PruneEntries will remove entries for all address not present in addressesToKeep

func (*ValidatorEnodeDB) RefreshValPeers

func (vet *ValidatorEnodeDB) RefreshValPeers(valset istanbul.ValidatorSet, ourAddress common.Address)

func (*ValidatorEnodeDB) RemoveEntry

func (vet *ValidatorEnodeDB) RemoveEntry(address common.Address) error

RemoveEntry will remove an entry from the table

func (*ValidatorEnodeDB) String

func (vet *ValidatorEnodeDB) String() string

func (*ValidatorEnodeDB) Upsert

func (vet *ValidatorEnodeDB) Upsert(valEnodeEntries map[common.Address]*AddressEntry) error

Upsert will update or insert a validator enode entry; given that the existing entry is older (determined by timestamp parameter) than the new one TODO - In addition to modifying the val_enode_db, this function also will disconnect

and/or connect the corresponding validator connenctions.  The validator connections
should be managed be a separate thread (see https://github.com/celo-org/celo-blockchain/issues/607)

func (*ValidatorEnodeDB) ValEnodeTableInfo

func (vet *ValidatorEnodeDB) ValEnodeTableInfo() (map[string]*ValEnodeEntryInfo, error)

type ValidatorEnodeHandler

type ValidatorEnodeHandler interface {
	// AddValidatorPeer adds a validator peer
	AddValidatorPeer(node *enode.Node, address common.Address)

	// RemoveValidatorPeer removes a validator peer
	RemoveValidatorPeer(node *enode.Node)

	// ReplaceValidatorPeers replace all validator peers for new list of enodeURLs
	ReplaceValidatorPeers(newNodes []*enode.Node)

	// Clear all validator peers
	ClearValidatorPeers()
}

ValidatorEnodeHandler is handler to Add/Remove events. Events execute within write lock

Jump to

Keyboard shortcuts

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