Documentation ¶
Index ¶
- type ValEnodeEntryInfo
- type ValidatorEnodeDB
- func (vet *ValidatorEnodeDB) Close() error
- func (vet *ValidatorEnodeDB) GetAddressFromNodeID(nodeID enode.ID) (common.Address, error)
- func (vet *ValidatorEnodeDB) GetHighestKnownVersionFromAddress(address common.Address) (uint, error)
- func (vet *ValidatorEnodeDB) GetNodeFromAddress(address common.Address) (*enode.Node, error)
- func (vet *ValidatorEnodeDB) GetValEnodes(valAddresses []common.Address) (map[common.Address]*istanbul.AddressEntry, error)
- func (vet *ValidatorEnodeDB) GetVersionFromAddress(address common.Address) (uint, error)
- func (vet *ValidatorEnodeDB) PruneEntries(addressesToKeep map[common.Address]bool) error
- func (vet *ValidatorEnodeDB) RefreshValPeers(valConnSet map[common.Address]bool, ourAddress common.Address)
- func (vet *ValidatorEnodeDB) RemoveEntry(address common.Address) error
- func (vet *ValidatorEnodeDB) String() string
- func (vet *ValidatorEnodeDB) UpdateQueryEnodeStats(valEnodeEntries []*istanbul.AddressEntry) error
- func (vet *ValidatorEnodeDB) UpsertHighestKnownVersion(valEnodeEntries []*istanbul.AddressEntry) error
- func (vet *ValidatorEnodeDB) UpsertVersionAndEnode(valEnodeEntries []*istanbul.AddressEntry) error
- func (vet *ValidatorEnodeDB) ValEnodeTableInfo() (map[string]*ValEnodeEntryInfo, error)
- type ValidatorEnodeHandler
- type VersionCertificateDB
- func (svdb *VersionCertificateDB) Close() error
- func (svdb *VersionCertificateDB) Get(address common.Address) (*VersionCertificateEntry, error)
- func (svdb *VersionCertificateDB) GetAll() ([]*VersionCertificateEntry, error)
- func (svdb *VersionCertificateDB) GetVersion(address common.Address) (uint, error)
- func (svdb *VersionCertificateDB) Info() (map[string]*VersionCertificateEntryInfo, error)
- func (svdb *VersionCertificateDB) Prune(addressesToKeep map[common.Address]bool) error
- func (svdb *VersionCertificateDB) Remove(address common.Address) error
- func (svdb *VersionCertificateDB) String() string
- func (svdb *VersionCertificateDB) Upsert(savEntries []*VersionCertificateEntry) ([]*VersionCertificateEntry, error)
- type VersionCertificateEntry
- type VersionCertificateEntryInfo
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 ¶
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 ¶
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 (*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 ¶
func (svdb *VersionCertificateDB) Get(address common.Address) (*VersionCertificateEntry, error)
Get gets the VersionCertificateEntry entry with address `address`. Returns an error if no entry exists.
func (*VersionCertificateDB) GetAll ¶
func (svdb *VersionCertificateDB) GetAll() ([]*VersionCertificateEntry, error)
GetAll gets each 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 ¶
func (svdb *VersionCertificateDB) Info() (map[string]*VersionCertificateEntryInfo, error)
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 ¶
func (svdb *VersionCertificateDB) Upsert(savEntries []*VersionCertificateEntry) ([]*VersionCertificateEntry, error)
Upsert inserts any new entries or entries with a Version higher than the existing version. Returns any new or updated entries
type VersionCertificateEntry ¶
type VersionCertificateEntry struct { Address common.Address PublicKey *ecdsa.PublicKey Version uint Signature []byte }
VersionCertificateEntry is an entry in the VersionCertificateDB. It's a signed message from a registered or active validator indicating the most recent version of its enode.
func (*VersionCertificateEntry) DecodeRLP ¶
func (entry *VersionCertificateEntry) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder, and load the VersionCertificateEntry fields from a RLP stream.
func (*VersionCertificateEntry) EncodeRLP ¶
func (entry *VersionCertificateEntry) EncodeRLP(w io.Writer) error
EncodeRLP serializes VersionCertificateEntry into the Ethereum RLP format.
func (*VersionCertificateEntry) String ¶
func (entry *VersionCertificateEntry) String() string
String gives a string representation of VersionCertificateEntry
type VersionCertificateEntryInfo ¶
type VersionCertificateEntryInfo struct { Address string `json:"address"` Version uint `json:"version"` }
VersionCertificateEntryInfo gives basic information for an entry in the DB