Store and prefer recent peers from trackers and local peer discovery

This commit is contained in:
shortcutme 2018-02-08 17:53:17 +01:00
parent 7d3fd6f5b6
commit 13e651c822
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 32 additions and 11 deletions
src/Peer

View file

@ -114,8 +114,14 @@ class Peer(object):
else:
return helper.packAddress(self.ip, self.port)
# Found a peer on tracker
def found(self):
# Found a peer from a source
def found(self, source="other"):
if source == "tracker":
self.reputation += 10
elif source == "local":
self.reputation += 30
if source in ("tracker", "local"):
self.site.peers_recent.appendleft(self)
self.time_found = time.time()
# Send a command to peer and return response value