Commit 15d0898d authored by Moul's avatar Moul
Browse files

[enh] check nodes are up: if not remove them from list.

- [fix] close socket after openning it.
parent 7d67f731
......@@ -7,7 +7,9 @@ import urllib.request
def discover_peers(ep):
peers = request(ep, "network/peers")["peers"]
endpoints = parse_endpoints(peers)
# Todo: discover network some nodes are missing
for ep in endpoints:
if best_node(ep, 0) is None: endpoints.remove(ep)
# Todo: discover network, some nodes are missing
### Todo: search for other nodes asking on other nodes because nodes are missing comperated to Sakia ###
return (endpoints)
......@@ -72,9 +74,9 @@ def best_node(ep, main):
if address in ep:
try:
s.connect((ep[address], port))
s.close()
return (address)
except: pass
s.close()
if main: print("Wrong node gived as argument"); exit()
return (None)
......
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