discv4

package
v0.0.0-...-2ace7f4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenRandomPublicKey

func GenRandomPublicKey(targetID enode.ID, targetCPL int) (v4wire.Pubkey, error)

GenRandomPublicKey generates a public key that, when hashed with Keccak256, yields a v4wire.Pubkey that has a common prefix length of targetCPL.

Types

type Client

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

func NewClient

func NewClient(privKey *ecdsa.PrivateKey, cfg *ClientConfig) *Client

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, pi PeerInfo) (*ethtest.Conn, error)

type ClientConfig

type ClientConfig struct {
	DialTimeout         time.Duration
	Caps                []p2p.Cap
	HighestProtoVersion uint
}

func DefaultClientConfig

func DefaultClientConfig() *ClientConfig

type CrawlDriver

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

func NewCrawlDriver

func NewCrawlDriver(dbc db.Client, cfg *CrawlDriverConfig) (*CrawlDriver, error)

func (*CrawlDriver) Close

func (d *CrawlDriver) Close()

func (*CrawlDriver) NewWorker

func (*CrawlDriver) NewWriter

func (*CrawlDriver) Tasks

func (d *CrawlDriver) Tasks() <-chan PeerInfo

type CrawlDriverConfig

type CrawlDriverConfig struct {
	Version          string
	CrawlWorkerCount int
	DialTimeout      time.Duration
	BootstrapPeers   []*enode.Node
	AddrDialType     config.AddrType
	MeterProvider    metric.MeterProvider
	TracerProvider   trace.TracerProvider
	LogErrors        bool
	KeepENR          bool
	UDPBufferSize    int
	UDPRespTimeout   time.Duration
}

func (*CrawlDriverConfig) CrawlerConfig

func (cfg *CrawlDriverConfig) CrawlerConfig() *CrawlerConfig

func (*CrawlDriverConfig) WriterConfig

func (cfg *CrawlDriverConfig) WriterConfig() *core.CrawlWriterConfig

type CrawlStrategy

type CrawlStrategy string

type Crawler

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

func (*Crawler) Work

func (c *Crawler) Work(ctx context.Context, task PeerInfo) (core.CrawlResult[PeerInfo], error)

type CrawlerConfig

type CrawlerConfig struct {
	DialTimeout  time.Duration
	AddrDialType config.AddrType
	MaxJitter    time.Duration
	LogErrors    bool
	KeepENR      bool
}

type Devp2pResult

type Devp2pResult struct {
	DialMaddrs       []ma.Multiaddr
	ConnectStartTime time.Time
	ConnectEndTime   time.Time
	IdentifyEndTime  time.Time
	ConnectError     error
	ConnectErrorStr  string
	ConnectMaddr     ma.Multiaddr
	Agent            string
	Protocols        []string
	Status           *eth.StatusPacket
}

type DialDriver

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

func NewDialDriver

func NewDialDriver(dbc db.Client, cfg *DialDriverConfig) (*DialDriver, error)

func (*DialDriver) Close

func (d *DialDriver) Close()

func (*DialDriver) NewWorker

func (d *DialDriver) NewWorker() (core.Worker[PeerInfo, core.DialResult[PeerInfo]], error)

func (*DialDriver) NewWriter

func (*DialDriver) Tasks

func (d *DialDriver) Tasks() <-chan PeerInfo

type DialDriverConfig

type DialDriverConfig struct {
	Version string
}

type Dialer

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

Dialer encapsulates a libp2p host that dials peers.

func (*Dialer) Work

func (d *Dialer) Work(ctx context.Context, task PeerInfo) (core.DialResult[PeerInfo], error)

Work takes the PeerInfo object and tries to figure out if the peer is still online.

type DiscV4Result

type DiscV4Result struct {
	// The time we received the first successful response
	RespondedAt *time.Time

	// The updated ethereum node record
	ENR *enode.Node

	// The multiaddress via which we have received a response
	ConnectMaddr ma.Multiaddr

	// The neighbors of the crawled peer
	RoutingTable *core.RoutingTable[PeerInfo]

	// The strategy used to crawl the peer
	Strategy CrawlStrategy

	// The time the draining of bucket entries was finished
	DoneAt time.Time

	// The combined error of crawling the peer's buckets
	Error error

	// The above error mapped to a known string
	ErrorStr string
}

type PeerInfo

type PeerInfo struct {
	*enode.Node
	// contains filtered or unexported fields
}

func NewPeerInfo

func NewPeerInfo(node *enode.Node) (PeerInfo, error)

func (PeerInfo) Addrs

func (p PeerInfo) Addrs() []ma.Multiaddr

func (PeerInfo) DeduplicationKey

func (p PeerInfo) DeduplicationKey() string

func (PeerInfo) DiscoveryPrefix

func (p PeerInfo) DiscoveryPrefix() uint64

func (PeerInfo) ID

func (p PeerInfo) ID() peer.ID

func (PeerInfo) Merge

func (p PeerInfo) Merge(other PeerInfo) PeerInfo

func (PeerInfo) TCPMaddr

func (p PeerInfo) TCPMaddr() ma.Multiaddr

func (PeerInfo) UDPMaddr

func (p PeerInfo) UDPMaddr() ma.Multiaddr

Jump to

Keyboard shortcuts

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