Commit 3ead33ce authored by Pascal Engélibert's avatar Pascal Engélibert

Client: Select only up peers

parent 226921d5
......@@ -61,19 +61,23 @@ def get_peers(host):
peers = [Peer(data["pubkey"], host[0], host[1], True)]
for peer in data["peers"]:
peers.append(Peer(peer["pubkey"], peer["host"], peer["port"], True))
peers.append(Peer(peer["pubkey"], peer["host"], peer["port"], peer["up"]))
return peers
def build_path(peers, receiver, layers=3):
if len(peers) < layers:
up_peers = []
for peer in peers:
if peer.up:
if len(up_peers) < layers:
return None, None
path = []
host = None
peer = None
for i in range(layers):
while True:
peer = random.choice(peers)
peer = random.choice(up_peers)
if not peer.pubkey in path:
......@@ -408,7 +408,7 @@ class ServerThread(Thread):
if "list" in url:
peers_list = []
for peer in self.peers:
peers_list.append({"pubkey":peer.pubkey, "host", "port":peer.port})
peers_list.append({"pubkey":peer.pubkey, "host", "port":peer.port, "up":peer.up})
resp["peers"] = peers_list
if "new" in url:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment