瀏覽代碼

p2p: add enode URL to PeerInfo (#17838)

Felix Lange 7 年之前
父節點
當前提交
1895059119
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      p2p/peer.go

+ 5 - 3
p2p/peer.go

@@ -425,9 +425,10 @@ 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
+	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
@@ -447,6 +448,7 @@ 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,