# NOISY-DEBUG: print("DEBUG: Calculating hash for domain:", domain)
return sha256(domain.encode("utf-8")).hexdigest()
+def update_last_access(domain: str):
+ # NOISY-DEBUG: print("DEBUG: Updating last_access for domain:", domain)
+
+ try:
+ c.execute("UPDATE instances SET last_access = ? WHERE domain = ?", [
+ time.time(),
+ domain
+ ])
+
+ except:
+ print("ERROR: failed SQL query:", domain)
+ sys.exit(255)
+
def get_peers(domain: str) -> str:
# NOISY-DEBUG: print("DEBUG: Getting peers for domain:", domain)
peers = None
except:
print("WARNING: Cannot fetch peers:", domain)
+ if peers is not None:
+ update_last_access(domain)
+
# NOISY-DEBUG: print("DEBUG: Returning peers[]:", type(peers))
return peers
if not res.ok:
print("WARNING: Cannot query JSON API:", domain, path, data, res.status_code)
raise
+ else:
+ update_last_access(domain)
doc = res.json()
# NOISY-DEBUG: print("DEBUG: Returning doc():", len(doc))
if json is None:
print("WARNING: Failed fetching nodeinfo from domain:", domain)
+ else:
+ update_last_access(domain)
# NOISY-DEBUG: print("DEBUG: Returning json():", len(json))
return json