Don't remove peers with atleast 5 sites

This commit is contained in:
shortcutme 2017-02-27 00:12:55 +01:00
parent ea635d4630
commit b65670b9e4
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 7 additions and 3 deletions

View File

@ -975,9 +975,13 @@ class Site(object):
need_to_close = len(connected_peers) - config.connected_limit
if closed < need_to_close:
sorted(connected_peers, key=lambda peer: peer.connection.sites) # Try to keep connections with more sites
for peer in connected_peers:
peer.remove()
for peer in sorted(connected_peers, key=lambda peer: peer.connection.sites): # Try to keep connections with more sites
if not peer.connection:
continue
if peer.connection.sites > 5:
break
peer.connection.close("Cleanup peers")
peer.connection = None
closed += 1
if closed >= need_to_close:
break