mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
Add an enode.Iterator that drives discovery by issuing a single FINDNODE per discovered peer, rotating the target through Drange sub-regions of the keyspace. Compared to RandomNodes (which wraps an alpha=3 Kademlia lookup that converges on a single target), this shape is geared for breadth: each peer is asked about a different slice of the keyspace, so aggregate coverage grows quickly without per-peer overlap. The two protocols expose different FINDNODE primitives, so the iterator threads a per-protocol queryFn: * discv5 takes a list of distances natively, so we just pass [256-d] for d in 0..Drange-1. * discv4 takes a target NodeID and replies with the K closest. To get an equivalent rotation, we pick a random pubkey whose Keccak256 starts with the desired prefix nibble. With Drange=16 that's ~16 random draws per call -- negligible compared to the network round trip. Concurrency is bounded by Workers (default 16). There is intentionally no rate limit: pacing is RTT-driven, ~Workers/RTT on the wire. Termination is implicit: when the work queue is empty AND no FINDNODE is in flight, the iterator closes its output and Next returns false. Close() short-circuits this for callers that want to bail early. Adapts the algorithm from github.com/cskiraly/fast-ethereum-crawler (dcrawl.nim) -- the prefix-rotation idea -- but drops its 1000 req/s rate limit in favour of the bounded worker pool. |
||
|---|---|---|
| .. | ||
| discover | ||
| dnsdisc | ||
| enode | ||
| enr | ||
| msgrate | ||
| nat | ||
| netutil | ||
| pipes | ||
| rlpx | ||
| tracker | ||
| config.go | ||
| config_toml.go | ||
| dial.go | ||
| dial_test.go | ||
| message.go | ||
| message_test.go | ||
| metrics.go | ||
| peer.go | ||
| peer_error.go | ||
| peer_test.go | ||
| protocol.go | ||
| server.go | ||
| server_nat.go | ||
| server_nat_test.go | ||
| server_test.go | ||
| transport.go | ||
| transport_test.go | ||
| util.go | ||
| util_test.go | ||