mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
p2p: add ENR to PeerInfo (#19816)
This commit is contained in:
parent
1204fa954f
commit
41fa412893
1 changed files with 9 additions and 3 deletions
12
p2p/peer.go
12
p2p/peer.go
|
|
@ -441,9 +441,11 @@ func (rw *protoRW) ReadMsg() (Msg, error) {
|
||||||
// peer. Sub-protocol independent fields are contained and initialized here, with
|
// peer. Sub-protocol independent fields are contained and initialized here, with
|
||||||
// protocol specifics delegated to all connected sub-protocols.
|
// protocol specifics delegated to all connected sub-protocols.
|
||||||
type PeerInfo struct {
|
type PeerInfo struct {
|
||||||
ID string `json:"id"` // Unique node identifier (also the encryption key)
|
ENR string `json:"enr,omitempty"` // Ethereum Node Record
|
||||||
Name string `json:"name"` // Name of the node, including client type, version, OS, custom data
|
Enode string `json:"enode"` // Node URL
|
||||||
Caps []string `json:"caps"` // Sum-protocols advertised by this particular peer
|
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 {
|
Network struct {
|
||||||
LocalAddress string `json:"localAddress"` // Local endpoint of the TCP data connection
|
LocalAddress string `json:"localAddress"` // Local endpoint of the TCP data connection
|
||||||
RemoteAddress string `json:"remoteAddress"` // Remote 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
|
// Assemble the generic peer metadata
|
||||||
info := &PeerInfo{
|
info := &PeerInfo{
|
||||||
|
Enode: p.Node().String(),
|
||||||
ID: p.ID().String(),
|
ID: p.ID().String(),
|
||||||
Name: p.Name(),
|
Name: p.Name(),
|
||||||
Caps: caps,
|
Caps: caps,
|
||||||
Protocols: make(map[string]interface{}),
|
Protocols: make(map[string]interface{}),
|
||||||
}
|
}
|
||||||
|
if p.Node().Seq() > 0 {
|
||||||
|
info.ENR = p.Node().String()
|
||||||
|
}
|
||||||
info.Network.LocalAddress = p.LocalAddr().String()
|
info.Network.LocalAddress = p.LocalAddr().String()
|
||||||
info.Network.RemoteAddress = p.RemoteAddr().String()
|
info.Network.RemoteAddress = p.RemoteAddr().String()
|
||||||
info.Network.Inbound = p.rw.is(inboundConn)
|
info.Network.Inbound = p.rw.is(inboundConn)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue