go-ethereum/p2p/enode
Felix Lange bc6569462d
p2p: use netip.Addr where possible (#29891)
enode.Node was recently changed to store a cache of endpoint information. The IP address in the cache is a netip.Addr. I chose that type over net.IP because it is just better. netip.Addr is meant to be used as a value type. Copying it does not allocate, it can be compared with ==, and can be used as a map key.

This PR changes most uses of Node.IP() into Node.IPAddr(), which returns the cached value directly without allocating.
While there are still some public APIs left where net.IP is used, I have converted all code used internally by p2p/discover to the new types. So this does change some public Go API, but hopefully not APIs any external code actually uses.

There weren't supposed to be any semantic differences resulting from this refactoring, however it does introduce one: In package p2p/netutil we treated the 0.0.0.0/8 network (addresses 0.x.y.z) as LAN, but netip.Addr.IsPrivate() doesn't. The treatment of this particular IP address range is controversial, with some software supporting it and others not. IANA lists it as special-purpose and invalid as a destination for a long time, so I don't know why I put it into the LAN list. It has now been marked as special in p2p/netutil as well.
2024-06-05 19:31:04 +02:00
..
idscheme_test.go all: new p2p node representation (#17643) 2018-09-25 00:59:00 +02:00
idscheme.go p2p/enode: fix endpoint determination for IPv6 (#29801) 2024-05-23 14:27:03 +02:00
iter_test.go p2p: initialize maps with known size (#27229) 2023-05-10 10:52:26 +02:00
iter.go p2p/enode: implement per-source timeout in FairMix (#25962) 2022-11-08 12:12:36 +01:00
localnode_test.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
localnode.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
node_test.go p2p/enode: fix endpoint determination for IPv6 (#29801) 2024-05-23 14:27:03 +02:00
node.go p2p/enode: fix TCPEndpoint (#29827) 2024-05-23 23:17:51 +02:00
nodedb_test.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
nodedb.go p2p: use netip.Addr where possible (#29891) 2024-06-05 19:31:04 +02:00
urlv4_test.go p2p/enode: mock DNS resolver in URL parsing test (#20252) 2019-11-07 16:40:37 +01:00
urlv4.go p2p/enode: fix endpoint determination for IPv6 (#29801) 2024-05-23 14:27:03 +02:00