aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/peer.go
diff options
context:
space:
mode:
authorKurkó Mihály <kurkomisi@users.noreply.github.com>2019-07-19 17:25:43 +0800
committerFelix Lange <fjl@twurst.com>2019-07-19 17:25:43 +0800
commita1f8549262567ddacac3d4180f8a6ca0826036a9 (patch)
treea8b531a957af71c4692524954af5494f4b35124f /p2p/peer.go
parente8c9579fb70165bdd2616d0a80163ba92d8c05c8 (diff)
downloadgo-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.tar
go-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.tar.gz
go-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.tar.bz2
go-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.tar.lz
go-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.tar.xz
go-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.tar.zst
go-tangerine-a1f8549262567ddacac3d4180f8a6ca0826036a9.zip
p2p: add ENR to PeerInfo (#19816)
Diffstat (limited to 'p2p/peer.go')
-rw-r--r--p2p/peer.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/p2p/peer.go b/p2p/peer.go
index d370894f1..372ba8d02 100644
--- a/p2p/peer.go
+++ b/p2p/peer.go
@@ -427,10 +427,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 {
- 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
+ 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
@@ -450,12 +451,15 @@ func (p *Peer) Info() *PeerInfo {
}
// Assemble the generic peer metadata
info := &PeerInfo{
- Enode: p.Node().String(),
+ Enode: p.Node().URLv4(),
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)