1
0
Fork 0
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:
Alessandro Boch 2016-12-05 11:09:39 -08:00 committed by GitHub
commit 3d32070063

View file

@ -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
}