observer

package
v0.0.0-...-ff78b6e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RLPxMessageIDHello      = 0
	RLPxMessageIDDisconnect = 1
	RLPxMessageIDPing       = 2
	RLPxMessageIDPong       = 3
)

https://github.com/ethereum/devp2p/blob/master/rlpx.md#p2p-capability

Variables

This section is empty.

Functions

func Handshake

func Handshake(
	ctx context.Context,
	ip net.IP,
	rlpxPort int,
	pubkey *ecdsa.PublicKey,
	myPrivateKey *ecdsa.PrivateKey,
) (*HelloMessage, *StatusMessage, *HandshakeError)

func IsClientIDBlacklisted

func IsClientIDBlacklisted(clientID string) bool

func NameFromClientID

func NameFromClientID(clientID string) string

func StatusLoggerLoop

func StatusLoggerLoop(ctx context.Context, db database.DB, networkID uint, period time.Duration, logger log.Logger)

Types

type Command

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

func NewCommand

func NewCommand() *Command

func (*Command) AddSubCommand

func (command *Command) AddSubCommand(subCommand *cobra.Command)

func (*Command) ExecuteContext

func (command *Command) ExecuteContext(ctx context.Context, runFunc func(ctx context.Context, flags CommandFlags, logger log.Logger) error) error

type CommandFlags

type CommandFlags struct {
	DataDir         string
	StatusLogPeriod time.Duration

	Chain     string
	Bootnodes string

	ListenPort  int
	NATDesc     string
	NetRestrict string

	NodeKeyFile string
	NodeKeyHex  string

	CrawlerConcurrency uint
	RefreshTimeout     time.Duration
	MaxPingTries       uint

	KeygenTimeout     time.Duration
	KeygenConcurrency uint

	HandshakeRefreshTimeout time.Duration
	HandshakeRetryDelay     time.Duration
	HandshakeMaxTries       uint

	ErigonLogPath string
}

type Crawler

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

func NewCrawler

func NewCrawler(
	transport DiscV4Transport,
	db database.DB,
	config CrawlerConfig,
	logger log.Logger,
) (*Crawler, error)

func (*Crawler) Run

func (crawler *Crawler) Run(ctx context.Context) error

type CrawlerConfig

type CrawlerConfig struct {
	Chain            string
	Bootnodes        []*enode.Node
	PrivateKey       *ecdsa.PrivateKey
	ConcurrencyLimit uint
	RefreshTimeout   time.Duration
	MaxPingTries     uint
	StatusLogPeriod  time.Duration

	HandshakeRefreshTimeout time.Duration
	HandshakeRetryDelay     time.Duration
	HandshakeMaxTries       uint

	KeygenTimeout     time.Duration
	KeygenConcurrency uint

	ErigonLogPath string
}

type Diplomacy

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

func NewDiplomacy

func NewDiplomacy(
	db database.DBRetrier,
	saveQueue *utils.TaskQueue,
	privateKey *ecdsa.PrivateKey,
	concurrencyLimit uint,
	refreshTimeout time.Duration,
	retryDelay time.Duration,
	maxHandshakeTries uint,
	statusLogPeriod time.Duration,
	logger log.Logger,
) *Diplomacy

func (*Diplomacy) Run

func (diplomacy *Diplomacy) Run(ctx context.Context) error

type Diplomat

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

func NewDiplomat

func NewDiplomat(
	node *enode.Node,
	privateKey *ecdsa.PrivateKey,
	handshakeLastErrors []database.HandshakeError,
	handshakeRefreshTimeout time.Duration,
	handshakeRetryDelay time.Duration,
	handshakeMaxTries uint,
	logger log.Logger,
) *Diplomat

func (*Diplomat) NextRetryDelay

func (diplomat *Diplomat) NextRetryDelay(handshakeErr *HandshakeError) time.Duration

func (*Diplomat) NextRetryTime

func (diplomat *Diplomat) NextRetryTime(handshakeErr *HandshakeError) time.Time

func (*Diplomat) Run

func (diplomat *Diplomat) Run(ctx context.Context) DiplomatResult

type DiplomatResult

type DiplomatResult struct {
	ClientID        *string
	NetworkID       *uint64
	EthVersion      *uint32
	HandshakeErr    *HandshakeError
	HasTransientErr bool
}

type DiscV4Transport

type DiscV4Transport interface {
	RequestENR(*enode.Node) (*enode.Node, error)
	Ping(*enode.Node) error
	FindNode(toNode *enode.Node, targetKey *ecdsa.PublicKey) ([]*enode.Node, error)
}

type HandshakeError

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

func NewHandshakeError

func NewHandshakeError(id HandshakeErrorID, wrappedErr error, param uint64) *HandshakeError

func (*HandshakeError) Error

func (e *HandshakeError) Error() string

func (*HandshakeError) StringCode

func (e *HandshakeError) StringCode() string

func (*HandshakeError) Unwrap

func (e *HandshakeError) Unwrap() error

type HandshakeErrorID

type HandshakeErrorID string
const (
	HandshakeErrorIDConnect           HandshakeErrorID = "connect"
	HandshakeErrorIDSetTimeout        HandshakeErrorID = "set-timeout"
	HandshakeErrorIDAuth              HandshakeErrorID = "auth"
	HandshakeErrorIDRead              HandshakeErrorID = "read"
	HandshakeErrorIDUnexpectedMessage HandshakeErrorID = "unexpected-message"
	HandshakeErrorIDDisconnectDecode  HandshakeErrorID = "disconnect-decode"
	HandshakeErrorIDDisconnect        HandshakeErrorID = "disconnect"
	HandshakeErrorIDHelloEncode       HandshakeErrorID = "hello-encode"
	HandshakeErrorIDHelloDecode       HandshakeErrorID = "hello-decode"
	HandshakeErrorIDStatusDecode      HandshakeErrorID = "status-decode"
)

type HelloMessage

type HelloMessage struct {
	Version    uint64
	ClientID   string
	Caps       []p2p.Cap
	ListenPort uint64
	Pubkey     []byte // secp256k1 public key

	// Ignore additional fields (for forward compatibility).
	Rest []rlp.RawValue `rlp:"tail"`
}

HelloMessage is the RLPx Hello message. (same as protoHandshake in p2p/peer.go) https://github.com/ethereum/devp2p/blob/master/rlpx.md#hello-0x00

type InterrogationError

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

func NewInterrogationError

func NewInterrogationError(id InterrogationErrorID, wrappedErr error) *InterrogationError

func (*InterrogationError) Error

func (e *InterrogationError) Error() string

func (*InterrogationError) Unwrap

func (e *InterrogationError) Unwrap() error

type InterrogationErrorID

type InterrogationErrorID int
const (
	InterrogationErrorPing InterrogationErrorID = iota + 1
	InterrogationErrorENRDecode
	InterrogationErrorIncompatibleForkID
	InterrogationErrorBlacklistedClientID
	InterrogationErrorKeygen
	InterrogationErrorFindNode
	InterrogationErrorFindNodeTimeout
)

type InterrogationResult

type InterrogationResult struct {
	Node               *enode.Node
	IsCompatFork       *bool
	HandshakeResult    *DiplomatResult
	HandshakeRetryTime *time.Time
	KeygenKeys         []*ecdsa.PublicKey
	Peers              []*enode.Node
}

type Interrogator

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

func NewInterrogator

func NewInterrogator(
	node *enode.Node,
	transport DiscV4Transport,
	forkFilter forkid.Filter,
	diplomat *Diplomat,
	handshakeRetryTime *time.Time,
	keygenTimeout time.Duration,
	keygenConcurrency uint,
	keygenSemaphore *semaphore.Weighted,
	keygenCachedKeys []*ecdsa.PublicKey,
	logger log.Logger,
) (*Interrogator, error)

func (*Interrogator) Run

type Server

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

func NewServer

func NewServer(ctx context.Context, flags CommandFlags, logger log.Logger) (*Server, error)

func (*Server) Bootnodes

func (server *Server) Bootnodes() []*enode.Node

func (*Server) Listen

func (server *Server) Listen(ctx context.Context) (*discover.UDPv4, error)

func (*Server) PrivateKey

func (server *Server) PrivateKey() *ecdsa.PrivateKey

type StatusMessage

type StatusMessage struct {
	ProtocolVersion uint32
	NetworkID       uint64
	TD              *big.Int
	Head            libcommon.Hash
	Genesis         libcommon.Hash
	ForkID          *forkid.ID     `rlp:"-"` // parsed from Rest if exists in v64+
	Rest            []rlp.RawValue `rlp:"tail"`
}

StatusMessage is the Ethereum Status message v63+. (same as StatusPacket in eth/protocols/eth/protocol.go) https://github.com/ethereum/devp2p/blob/master/caps/eth.md#status-0x00

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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