From 41fa41289371fcb0221b314080a2ee7dd39cbab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kurk=C3=B3=20Mih=C3=A1ly?= Date: Fri, 19 Jul 2019 12:25:43 +0300 Subject: [PATCH] p2p: add ENR to PeerInfo (#19816) --- p2p/peer.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/p2p/peer.go b/p2p/peer.go index 0ae44a4753..523780d132 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -441,9 +441,11 @@ func (rw *protoRW) ReadMsg() (Msg, error) { // peer. Sub-protocol independent fields are contained and initialized here, with // protocol specifics delegated to all connected sub-protocols. type PeerInfo struct { - ID string `json:"id"` // Unique node identifier (also the encryption key) - Name string `json:"name"` // Name of the node, including client type, version, OS, custom data - Caps []string `json:"caps"` // Sum-protocols advertised by this particular peer + ENR string `json:"enr,omitempty"` // Ethereum Node Record + Enode string `json:"enode"` // Node URL + ID string `json:"id"` // Unique node identifier + Name string `json:"name"` // Name of the node, including client type, version, OS, custom data + Caps []string `json:"caps"` // Protocols advertised by this peer Network struct { LocalAddress string `json:"localAddress"` // Local endpoint of the TCP data connection RemoteAddress string `json:"remoteAddress"` // Remote endpoint of the TCP data connection @@ -463,11 +465,15 @@ func (p *Peer) Info() *PeerInfo { } // Assemble the generic peer metadata info := &PeerInfo{ + Enode: p.Node().String(), ID: p.ID().String(), Name: p.Name(), Caps: caps, Protocols: make(map[string]interface{}), } + if p.Node().Seq() > 0 { + info.ENR = p.Node().String() + } info.Network.LocalAddress = p.LocalAddr().String() info.Network.RemoteAddress = p.RemoteAddr().String() info.Network.Inbound = p.rw.is(inboundConn)