common

package
v0.0.0-...-633321c Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: GPL-3.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfo

type ClientInfo struct {
	ClientType      string
	SoftwareVersion uint64
	Capabilities    []p2p.Cap
	NetworkID       uint64
	ForkID          forkid.ID
	Blockheight     string
	TotalDifficulty *big.Int
	HeadHash        common.Hash
}

type NodeJSON

type NodeJSON struct {
	Seq uint64      `json:"seq"`
	N   *enode.Node `json:"record"`

	// The score tracks how many liveness checks were performed. It is incremented by one
	// every time the node passes a check, and halved every time it doesn't.
	Score int `json:"score,omitempty"`
	// These two track the time of last successful contact.
	FirstResponse time.Time `json:"firstResponse,omitempty"`
	LastResponse  time.Time `json:"lastResponse,omitempty"`
	// This one tracks the time of our last attempt to contact the node.
	LastCheck time.Time `json:"lastCheck,omitempty"`

	Info *ClientInfo `json:"clientInfo,omitempty"`

	TooManyPeers bool `json:"tooManyPeers,omitempty"`
}

type NodeSet

type NodeSet map[enode.ID]NodeJSON

NodeSet is the nodes.json file format. It holds a set of node records as a JSON object.

func LoadNodesJSON

func LoadNodesJSON(file string) NodeSet

func (NodeSet) Add

func (ns NodeSet) Add(nodes ...*enode.Node)

Add ensures the given nodes are present in the set.

func (NodeSet) Nodes

func (ns NodeSet) Nodes() []*enode.Node

Nodes returns the node records contained in the set.

func (NodeSet) TopN

func (ns NodeSet) TopN(n int) NodeSet

TopN returns the top n nodes by score as a new set.

func (NodeSet) Verify

func (ns NodeSet) Verify() error

Verify performs integrity checks on the node set.

func (NodeSet) WriteNodesJSON

func (nodes NodeSet) WriteNodesJSON(file string)

Jump to

Keyboard shortcuts

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