models

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyNetworkId = uint64(0)
View Source
const (
	IPInfoTTL = 30 * 24 * time.Hour // 30 days
)

Variables

View Source
var (
	// GoblaUnknown
	Unknown string = "unknown"

	// avail Clients
	Geth         ClientName = "geth"
	Erigon       ClientName = "erigon"
	Reth         ClientName = "reth"
	Nethermind   ClientName = "nethermind"
	Besu         ClientName = "besu"
	OpenEthereum ClientName = "open-ethereum"
	Parity       ClientName = "parity"
	Reosc        ClientName = "reosc"
	EthereumJS   ClientName = "ethereum-js"
	NimbusEth1   ClientName = "nimbus-eth1"

	// avail OSs
	LinuxOS   ClientOS = "linux"
	WindowsOS ClientOS = "windows"
	MaxOS     ClientOS = "mac"
	FreeBsdOS ClientOS = "free-bsd"

	// Client Archs
	Amd64Arch ClientArch = "amd64"
	X86Arch   ClientArch = "x86"
	ArmArch   ClientArch = "arm"

	// Client Languages
	GoLanguage         ClientLanguage = "go"
	RustLanguage       ClientLanguage = "rust"
	JavaLanguage       ClientLanguage = "java"
	JavaScriptLanguage ClientLanguage = "js"
	DotnetLanguage     ClientLanguage = "dotnet"
	NimLanguage        ClientLanguage = "nim"
)
View Source
var PrivateIPNetworks = []net.IPNet{
	net.IPNet{
		IP:   net.ParseIP("10.0.0.0"),
		Mask: net.CIDRMask(8, 32),
	},
	net.IPNet{
		IP:   net.ParseIP("172.16.0.0"),
		Mask: net.CIDRMask(12, 32),
	},
	net.IPNet{
		IP:   net.ParseIP("192.168.0.0"),
		Mask: net.CIDRMask(16, 32),
	},
}
View Source
var ValidArchs = map[ClientArch][]string{
	Amd64Arch: {"amd64", "x64"},
	X86Arch:   {"x86_64", "86"},
	ArmArch:   {"arm", "arm64"},
}
View Source
var ValidClientNames = map[ClientName][]string{
	Geth:         {"geth", "go-ethereum"},
	Reth:         {"reth"},
	Erigon:       {"erigon"},
	Nethermind:   {"nethermind"},
	Besu:         {"besu"},
	OpenEthereum: {"openethereum"},
	Parity:       {"parity"},
	EthereumJS:   {"ethereum-js"},
	NimbusEth1:   {"nimbus", "nim"},
}

Valid strings

View Source
var ValidLanguages = map[ClientLanguage][]string{
	GoLanguage:         {"go"},
	RustLanguage:       {"rust", "reth"},
	JavaLanguage:       {"java", "arm64"},
	JavaScriptLanguage: {"js", "nodejs"},
	DotnetLanguage:     {"arm", "arm64"},
	NimLanguage:        {"nim", "nimvm"},
}
View Source
var ValidOSs = map[ClientOS][]string{
	LinuxOS:   {"linux", "ubuntu"},
	WindowsOS: {"win", "windows"},
	MaxOS:     {"macos", "osx"},
	FreeBsdOS: {"free", "bsd"},
}

Functions

func CustomToString

func CustomToString[T ClientName | ClientOS | ClientArch | ClientLanguage](s T) string

func IsIPPublic

func IsIPPublic(ip net.IP) bool

func ParseBootnodes

func ParseBootnodes(bnodes []string) ([]*enode.Node, error)

func ParseStringToEnode

func ParseStringToEnode(enr string) *enode.Node

func PubkeyToString

func PubkeyToString(pub *ecdsa.PublicKey) string

func StringToPubkey

func StringToPubkey(str string) (*ecdsa.PublicKey, error)

Types

type ChainDetails

type ChainDetails struct {
	ForkID          forkid.ID
	ProtocolVersion uint32
	HeadHash        common.Hash
	NetworkID       uint64
	TotalDifficulty *big.Int
}

func (*ChainDetails) IsEmpty

func (d *ChainDetails) IsEmpty() bool

type ClientArch

type ClientArch string

type ClientLanguage

type ClientLanguage string

type ClientName

type ClientName string

type ClientOS

type ClientOS string

type ConnectionAttempt

type ConnectionAttempt struct {
	Timestamp  time.Time
	ID         enode.ID
	Status     ConnectionStatus
	Error      string
	Latency    time.Duration
	Deprecable bool
}

func NewConnectionAttempt

func NewConnectionAttempt(id enode.ID) ConnectionAttempt

type ConnectionStatus

type ConnectionStatus int8
const (
	NotAttempted ConnectionStatus = iota
	FailedConnection
	SuccessfulConnection
)

func (ConnectionStatus) String

func (s ConnectionStatus) String() (str string)

type DiscoveryType

type DiscoveryType int8
const (
	UnknownDiscovery DiscoveryType = iota
	Discovery4
	Discovery5
	CsvFile
)

func (DiscoveryType) String

func (t DiscoveryType) String() string

type ENR

type ENR struct {
	Timestamp time.Time
	Node      *enode.Node
	Record    *ogEnr.Record
	DiscType  DiscoveryType
	ID        enode.ID
	IP        string
	UDP       int
	TCP       int
	Pubkey    string
	Score     int
	Seq       uint64
}

Basic structure that can be readed from the discovery services

func NewENR

func NewENR(opts ...ENRoption) (*ENR, error)

func (ENR) CSVheaders

func (n ENR) CSVheaders() []string

func (*ENR) ComposeCSVItems

func (n *ENR) ComposeCSVItems() []interface{}

func (*ENR) GetHostInfo

func (n *ENR) GetHostInfo() *HostInfo

func (*ENR) IsValid

func (n *ENR) IsValid() bool

type ENRoption

type ENRoption func(*ENR) error

func FromCSVline

func FromCSVline(line []string) ENRoption

func FromDiscv4

func FromDiscv4(en *enode.Node) ENRoption

the Discv4 Node won't search for the Eth2data and so on (could be still worth look for it?)

func WithTimestamp

func WithTimestamp(t time.Time) ENRoption

WithTimestamp adds any given timestamp into any given ENR

type EnodeSet

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

func NewEnodeSet

func NewEnodeSet() *EnodeSet

func (*EnodeSet) AddNode

func (s *EnodeSet) AddNode(n *ENR) error

func (*EnodeSet) GetENRs

func (s *EnodeSet) GetENRs() []*ENR

func (*EnodeSet) Len

func (s *EnodeSet) Len() int

func (*EnodeSet) PeerRows

func (s *EnodeSet) PeerRows() [][]interface{}

func (*EnodeSet) RowComposer

func (s *EnodeSet) RowComposer(rawRow []interface{}) []string

type HostInfo

type HostInfo struct {
	ID     enode.ID
	Pubkey *ecdsa.PublicKey
	IP     string
	TCP    int
}

required info to connect the remote node

type IPInfo

type IPInfo struct {
	IPInfoMsg
	ExpirationTime time.Time
}

type IPInfoMsg

type IPInfoMsg struct {
	IP            string  `json:"query"`
	Status        string  `json:"status"`
	Continent     string  `json:"continent"`
	ContinentCode string  `json:"continentCode"`
	Country       string  `json:"country"`
	CountryCode   string  `json:"countryCode"`
	Region        string  `json:"region"`
	RegionName    string  `json:"regionName"`
	City          string  `json:"city"`
	Zip           string  `json:"zip"`
	Lat           float64 `json:"lat"`
	Lon           float64 `json:"lon"`
	Isp           string  `json:"isp"`
	Org           string  `json:"org"`
	As            string  `json:"as"`
	AsName        string  `json:"asname"`
	Mobile        bool    `json:"mobile"`
	Proxy         bool    `json:"proxy"`
	Hosting       bool    `json:"hosting"`
}

IP-API message structure

func (*IPInfoMsg) IsEmpty

func (m *IPInfoMsg) IsEmpty() bool

Returns if the struct reply from the IP API is empty

type IPInfoResponse

type IPInfoResponse struct {
	IPInfo       IPInfo
	DelayTime    time.Duration
	AttemptsLeft int
	Err          error
}

type NodeInfo

type NodeInfo struct {
	Timestamp time.Time
	ID        enode.ID
	HostInfo
	ethtest.HandshakeDetails
	ChainDetails
}

func NewNodeInfo

func NewNodeInfo(id enode.ID, opts ...NodeInfoOption) (*NodeInfo, error)

func (*NodeInfo) UpdateTimestamp

func (n *NodeInfo) UpdateTimestamp()

type NodeInfoOption

type NodeInfoOption func(*NodeInfo) error

func WithChainDetails

func WithChainDetails(cd ChainDetails) NodeInfoOption

WithHostInfo adds the give host info to the NodeInfo struct

func WithHandShakeDetails

func WithHandShakeDetails(d ethtest.HandshakeDetails) NodeInfoOption

WithHandshakeDetails adds the give handshake info to the NodeInfo struct

func WithHostInfo

func WithHostInfo(hInfo HostInfo) NodeInfoOption

WithHostInfo adds the give host info to the NodeInfo struct

type RemoteNodeClient

type RemoteNodeClient struct {
	RawClientName      string
	ClientName         ClientName
	ClientVersion      string
	ClientCleanVersion string
	ClientOS           ClientOS
	ClientArch         ClientArch
	ClientLanguage     ClientLanguage
}

func ParseUserAgent

func ParseUserAgent(rawString string) RemoteNodeClient

Jump to

Keyboard shortcuts

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