Commit 6d56fc59 authored by Petar Radovic's avatar Petar Radovic Committed by GitHub

Peer added fix (#552)

* peer added fix
parent 7b3d9632
...@@ -131,19 +131,19 @@ func (r *peerRegistry) addIfNotExists(c network.Conn, overlay swarm.Address) (ex ...@@ -131,19 +131,19 @@ func (r *peerRegistry) addIfNotExists(c network.Conn, overlay swarm.Address) (ex
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
if _, exists := r.underlays[overlay.ByteString()]; exists {
return true
}
if _, ok := r.connections[peerID]; !ok { if _, ok := r.connections[peerID]; !ok {
r.connections[peerID] = make(map[network.Conn]struct{}) r.connections[peerID] = make(map[network.Conn]struct{})
} }
r.connections[peerID][c] = struct{}{} r.connections[peerID][c] = struct{}{}
r.streams[peerID] = make(map[network.Stream]context.CancelFunc) r.streams[peerID] = make(map[network.Stream]context.CancelFunc)
r.underlays[overlay.ByteString()] = peerID
r.overlays[peerID] = overlay
return false
if _, exists := r.underlays[overlay.ByteString()]; !exists {
r.underlays[overlay.ByteString()] = peerID
r.overlays[peerID] = overlay
return false
}
return true
} }
func (r *peerRegistry) peerID(overlay swarm.Address) (peerID libp2ppeer.ID, found bool) { func (r *peerRegistry) peerID(overlay swarm.Address) (peerID libp2ppeer.ID, found bool) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment