p2p/enode: fix TCPEndpoint (#29827)

This commit is contained in:
Aaron Chen 2024-05-24 05:17:51 +08:00 committed by Pratik Patil
parent be1e580459
commit b2c178d935
No known key found for this signature in database
GPG key ID: AFDCA496554874B3

View file

@ -189,7 +189,7 @@ func (n *Node) TCP() int {
return int(n.tcp) return int(n.tcp)
} }
// UDPEndpoint returns the announced TCP endpoint. // UDPEndpoint returns the announced UDP endpoint.
func (n *Node) UDPEndpoint() (netip.AddrPort, bool) { func (n *Node) UDPEndpoint() (netip.AddrPort, bool) {
if !n.ip.IsValid() || n.ip.IsUnspecified() || n.udp == 0 { if !n.ip.IsValid() || n.ip.IsUnspecified() || n.udp == 0 {
return netip.AddrPort{}, false return netip.AddrPort{}, false
@ -202,7 +202,7 @@ func (n *Node) TCPEndpoint() (netip.AddrPort, bool) {
if !n.ip.IsValid() || n.ip.IsUnspecified() || n.tcp == 0 { if !n.ip.IsValid() || n.ip.IsUnspecified() || n.tcp == 0 {
return netip.AddrPort{}, false return netip.AddrPort{}, false
} }
return netip.AddrPortFrom(n.ip, n.udp), true return netip.AddrPortFrom(n.ip, n.tcp), true
} }
// Pubkey returns the secp256k1 public key of the node, if present. // Pubkey returns the secp256k1 public key of the node, if present.