mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1583 from sanimej/peers
Check for node's presence in networkDB's node map before accessing.
This commit is contained in:
commit
3d32070063
1 changed files with 6 additions and 4 deletions
|
@ -211,10 +211,12 @@ func (nDB *NetworkDB) Peers(nid string) []PeerInfo {
|
|||
defer nDB.RUnlock()
|
||||
peers := make([]PeerInfo, 0, len(nDB.networkNodes[nid]))
|
||||
for _, nodeName := range nDB.networkNodes[nid] {
|
||||
peers = append(peers, PeerInfo{
|
||||
Name: nDB.nodes[nodeName].Name,
|
||||
IP: nDB.nodes[nodeName].Addr.String(),
|
||||
})
|
||||
if node, ok := nDB.nodes[nodeName]; ok {
|
||||
peers = append(peers, PeerInfo{
|
||||
Name: node.Name,
|
||||
IP: node.Addr.String(),
|
||||
})
|
||||
}
|
||||
}
|
||||
return peers
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue