Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Fixed updating peers
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrevinnoc committed Mar 10, 2021
1 parent 7e0b0a9 commit b21cf11
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions future.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def sendRegisterRequestToPeer(url):
elif peer != hostname:
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Same as origin")
return "Same as origin"
else:
Expand All @@ -114,6 +115,7 @@ def sendRegisterRequestToPeer(url):
peerRegistryTransaction.commit()
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Registered with http")
return "Registered with http"
except:
Expand All @@ -129,6 +131,7 @@ def sendRegisterRequestToPeer(url):
peerRegistryTransaction.commit()
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Registered with https")
return "Registered with https"
except:
Expand Down Expand Up @@ -163,6 +166,7 @@ def sendAnswerRequestToPeer(url, query, queryVector, queryLanguage,
result = r.json()["result"]
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Obtained with http")
return {"urls": list(zip(result["urls"], result["url_scores"]))}
except:
Expand All @@ -180,13 +184,15 @@ def sendAnswerRequestToPeer(url, query, queryVector, queryLanguage,
result = r.json()["result"]
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Obtained with https")
return {
"urls": list(zip(result["urls"], result["url_scores"]))
}
except:
try:
listOfPeers.remove(peer)
numberOfPeers -= 1
except:
pass
print("Could not connect with peer")
Expand Down Expand Up @@ -220,6 +226,7 @@ def sendImagesAnswerRequestToPeer(url, query, queryVector, queryLanguage,
result = r.json()["result"]
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Obtained with http")
return {
"images": list(zip(result["images"], result["images_scores"]))
Expand All @@ -239,6 +246,7 @@ def sendImagesAnswerRequestToPeer(url, query, queryVector, queryLanguage,
result = r.json()["result"]
listOfPeers.append(peer)
listOfPeers = list(set(listOfPeers))
numberOfPeers += 1
print("Obtained with https")
return {
"images":
Expand All @@ -247,6 +255,7 @@ def sendImagesAnswerRequestToPeer(url, query, queryVector, queryLanguage,
except:
try:
listOfPeers.remove(peer)
numberOfPeers -= 1
except:
pass
print("Could not connect with peer")
Expand Down

0 comments on commit b21cf11

Please sign in to comment.