mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
p2p: removed quic accessor
This commit is contained in:
parent
94500ae52b
commit
f3ab1b3df1
3 changed files with 13 additions and 25 deletions
|
|
@ -298,7 +298,7 @@ func (ln *LocalNode) sign() {
|
||||||
panic(fmt.Errorf("enode: can't verify local record: %v", err))
|
panic(fmt.Errorf("enode: can't verify local record: %v", err))
|
||||||
}
|
}
|
||||||
ln.cur.Store(n)
|
ln.cur.Store(n)
|
||||||
log.Info("New local node record", "seq", ln.seq, "id", n.ID(), "ip", n.IPAddr(), "udp", n.UDP(), "tcp", n.TCP(), "quic", n.QUIC())
|
log.Info("New local node record", "seq", ln.seq, "id", n.ID(), "ip", n.IPAddr(), "udp", n.UDP(), "tcp", n.TCP())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ln *LocalNode) bumpSeq() {
|
func (ln *LocalNode) bumpSeq() {
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,9 @@ type Node struct {
|
||||||
r enr.Record
|
r enr.Record
|
||||||
id ID
|
id ID
|
||||||
// endpoint information
|
// endpoint information
|
||||||
ip netip.Addr
|
ip netip.Addr
|
||||||
udp uint16
|
udp uint16
|
||||||
tcp uint16
|
tcp uint16
|
||||||
quic uint16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New wraps a node record. The record must be valid according to the given
|
// New wraps a node record. The record must be valid according to the given
|
||||||
|
|
@ -106,7 +105,6 @@ func (n *Node) setIP4(ip netip.Addr) {
|
||||||
n.ip = ip
|
n.ip = ip
|
||||||
n.Load((*enr.UDP)(&n.udp))
|
n.Load((*enr.UDP)(&n.udp))
|
||||||
n.Load((*enr.TCP)(&n.tcp))
|
n.Load((*enr.TCP)(&n.tcp))
|
||||||
n.Load((*enr.QUIC)(&n.quic))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) setIP6(ip netip.Addr) {
|
func (n *Node) setIP6(ip netip.Addr) {
|
||||||
|
|
@ -121,9 +119,6 @@ func (n *Node) setIP6(ip netip.Addr) {
|
||||||
if err := n.Load((*enr.TCP6)(&n.tcp)); err != nil {
|
if err := n.Load((*enr.TCP6)(&n.tcp)); err != nil {
|
||||||
n.Load((*enr.TCP)(&n.tcp))
|
n.Load((*enr.TCP)(&n.tcp))
|
||||||
}
|
}
|
||||||
if err := n.Load((*enr.QUIC6)(&n.quic)); err != nil {
|
|
||||||
n.Load((*enr.QUIC)(&n.quic))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustParse parses a node record or enode:// URL. It panics if the input is invalid.
|
// MustParse parses a node record or enode:// URL. It panics if the input is invalid.
|
||||||
|
|
@ -189,11 +184,6 @@ func (n *Node) TCP() int {
|
||||||
return int(n.tcp)
|
return int(n.tcp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// QUIC returns the QUIC port of the node.
|
|
||||||
func (n *Node) QUIC() int {
|
|
||||||
return int(n.quic)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UDPEndpoint returns the announced UDP 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 {
|
||||||
|
|
@ -212,10 +202,12 @@ func (n *Node) TCPEndpoint() (netip.AddrPort, bool) {
|
||||||
|
|
||||||
// QUICEndpoint returns the announced QUIC endpoint.
|
// QUICEndpoint returns the announced QUIC endpoint.
|
||||||
func (n *Node) QUICEndpoint() (netip.AddrPort, bool) {
|
func (n *Node) QUICEndpoint() (netip.AddrPort, bool) {
|
||||||
if !n.ip.IsValid() || n.ip.IsUnspecified() || n.quic == 0 {
|
var quic enr.QUIC
|
||||||
|
n.Load(&quic)
|
||||||
|
if !n.ip.IsValid() || n.ip.IsUnspecified() || quic == 0 {
|
||||||
return netip.AddrPort{}, false
|
return netip.AddrPort{}, false
|
||||||
}
|
}
|
||||||
return netip.AddrPortFrom(n.ip, n.quic), true
|
return netip.AddrPortFrom(n.ip, uint16(quic)), true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pubkey returns the secp256k1 public key of the node, if present.
|
// Pubkey returns the secp256k1 public key of the node, if present.
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,11 @@ func TestPythonInterop(t *testing.T) {
|
||||||
func TestNodeEndpoints(t *testing.T) {
|
func TestNodeEndpoints(t *testing.T) {
|
||||||
id := HexID("00000000000000806ad9b61fa5ae014307ebdc964253adcd9f2c0a392aa11abc")
|
id := HexID("00000000000000806ad9b61fa5ae014307ebdc964253adcd9f2c0a392aa11abc")
|
||||||
type endpointTest struct {
|
type endpointTest struct {
|
||||||
name string
|
name string
|
||||||
node *Node
|
node *Node
|
||||||
wantIP netip.Addr
|
wantIP netip.Addr
|
||||||
wantUDP int
|
wantUDP int
|
||||||
wantTCP int
|
wantTCP int
|
||||||
wantQUIC int
|
|
||||||
}
|
}
|
||||||
tests := []endpointTest{
|
tests := []endpointTest{
|
||||||
{
|
{
|
||||||
|
|
@ -231,9 +230,6 @@ func TestNodeEndpoints(t *testing.T) {
|
||||||
if test.wantTCP != test.node.TCP() {
|
if test.wantTCP != test.node.TCP() {
|
||||||
t.Errorf("node has wrong TCP port %d, want %d", test.node.TCP(), test.wantTCP)
|
t.Errorf("node has wrong TCP port %d, want %d", test.node.TCP(), test.wantTCP)
|
||||||
}
|
}
|
||||||
if test.wantQUIC != test.node.QUIC() {
|
|
||||||
t.Errorf("node has wrong QUIC port %d, want %d", test.node.QUIC(), test.wantQUIC)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue