enodes

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: GPL-3.0, GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValEnodeEntryInfo

type ValEnodeEntryInfo struct {
	PublicKey                    string `json:"publicKey"`
	Enode                        string `json:"enode"`
	Version                      uint   `json:"version"`
	HighestKnownVersion          uint   `json:"highestKnownVersion"`
	NumQueryAttemptsForHKVersion uint   `json:"numQueryAttemptsForHKVersion"`
	LastQueryTimestamp           string `json:"lastQueryTimestamp"` // Unix timestamp
}

ValEnodeEntryInfo contains information for an entry of the val enode table

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

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

GetHighestKnownVersionFromAddress will return the highest known version for an address if it's known

func (*ValidatorEnodeDB) GetNodeFromAddress

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

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

func (*ValidatorEnodeDB) GetValEnodes

func (vet *ValidatorEnodeDB) GetValEnodes(valAddresses []common.Address) (map[common.Address]*istanbul.AddressEntry, error)

GetValEnodes will return entries in the valEnodeDB filtered on the valAddresses parameter. If it's set to nil, then no filter will be applied.

func (*ValidatorEnodeDB) GetVersionFromAddress

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

GetVersionFromAddress will return the version 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(valConnSet map[common.Address]bool, 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) UpdateQueryEnodeStats

func (vet *ValidatorEnodeDB) UpdateQueryEnodeStats(valEnodeEntries []*istanbul.AddressEntry) error

UpdateQueryEnodeStats function will do the following 1. Increment each entry's NumQueryAttemptsForHKVersion by 1 is existing HighestKnownVersion is the same 2. Set each entry's LastQueryTimestamp to the current time

func (*ValidatorEnodeDB) UpsertHighestKnownVersion

func (vet *ValidatorEnodeDB) UpsertHighestKnownVersion(valEnodeEntries []*istanbul.AddressEntry) error

UpsertHighestKnownVersion function will do the following 1. Check if the updated HighestKnownVersion is higher than the existing HighestKnownVersion 2. Update the fields HighestKnownVersion, NumQueryAttempsForHKVersion, and PublicKey

func (*ValidatorEnodeDB) UpsertVersionAndEnode

func (vet *ValidatorEnodeDB) UpsertVersionAndEnode(valEnodeEntries []*istanbul.AddressEntry) error

UpsertVersionAndEnode will do the following 1. Check if the updated Version higher than the existing Version 2. Update Node, Version, HighestKnownVersion (if it's less than the new Version) 3. If the Node has been updated, establish new validator peer

func (*ValidatorEnodeDB) ValEnodeTableInfo

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

ValEnodeTableInfo gives basic information for each entry of the table

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

type VersionCertificateDB

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

VersionCertificateDB stores

func OpenVersionCertificateDB

func OpenVersionCertificateDB(path string) (*VersionCertificateDB, error)

OpenVersionCertificateDB opens a signed announce version database for storing VersionCertificates. If no path is given an in-memory, temporary database is constructed.

func (*VersionCertificateDB) Close

func (svdb *VersionCertificateDB) Close() error

Close flushes and closes the database files.

func (*VersionCertificateDB) Get

Get gets the istanbul.VersionCertificateEntry entry with address `address`. Returns an error if no entry exists.

func (*VersionCertificateDB) GetAll

GetAll gets each istanbul.VersionCertificateEntry in the db

func (*VersionCertificateDB) GetVersion

func (svdb *VersionCertificateDB) GetVersion(address common.Address) (uint, error)

GetVersion gets the version for the entry with address `address` Returns an error if no entry exists

func (*VersionCertificateDB) Info

Info gives a map VersionCertificateEntryInfo where each key is the address. Intended for RPC use

func (*VersionCertificateDB) Prune

func (svdb *VersionCertificateDB) Prune(addressesToKeep map[common.Address]bool) error

Prune will remove entries for all addresses not present in addressesToKeep

func (*VersionCertificateDB) Remove

func (svdb *VersionCertificateDB) Remove(address common.Address) error

Remove will remove an entry from the table

func (*VersionCertificateDB) String

func (svdb *VersionCertificateDB) String() string

String gives a string representation of the entire db

func (*VersionCertificateDB) Upsert

Upsert inserts any new entries or entries with a Version higher than the existing version. Returns any new or updated entries

type VersionCertificateEntryInfo

type VersionCertificateEntryInfo struct {
	Address string `json:"address"`
	Version uint   `json:"version"`
}

VersionCertificateEntryInfo gives basic information for an entry in the DB

Jump to

Keyboard shortcuts

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