From 349d937806201188473d6f8c26d256136401d517 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 23 Jun 2023 18:26:15 +0200 Subject: [PATCH] Continued: - update total peer count in centralized fetch_instances(), not in individual network's functions --- fba/http/federation.py | 9 +++++++-- fba/networks/lemmy.py | 3 --- fba/networks/misskey.py | 3 --- fba/networks/peertube.py | 3 --- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/fba/http/federation.py b/fba/http/federation.py index ad24959..fdaec59 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -86,6 +86,11 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("Fetching instances for domain='%s',software='%s'", domain, software) peerlist = fetch_peers(domain, software) + logger.debug("peerlist[]='%s'", type(peerlist)) + if isinstance(peerlist, list): + logger.debug("Invoking instances.set_total_peerlist(%s,%d) ...", domain, len(peerlist)) + instances.set_total_peers(domain, peerlist) + if peerlist is None: logger.warning("Cannot fetch peers: domain='%s'", domain) return @@ -100,9 +105,9 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: # Skip "None" types as tidup.domain() cannot parse them continue - logger.debug("instance='%s' - BEFORE", instance) + logger.debug("instance='%s' - BEFORE!", instance) instance = tidyup.domain(instance) - logger.debug("instance='%s' - AFTER", instance) + logger.debug("instance='%s' - AFTER!", instance) if instance == "": logger.warning("Empty instance after tidyup.domain(), domain='%s'", domain) diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 2752fa6..e8bba35 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -75,9 +75,6 @@ def fetch_peers(domain: str) -> list: logger.warning("Exception during fetching JSON: domain='%s',exception[%s]:'%s'", domain, type(exception), str(exception)) instances.set_last_error(domain, exception) - logger.debug("Adding %d for domain='%s'", len(peers), domain) - instances.set_total_peers(domain, peers) - logger.debug("peers()=%d - EXIT!", len(peers)) return peers diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index 1320d06..fa169c7 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -119,9 +119,6 @@ def fetch_peers(domain: str) -> list: logger.debug("Host returned same set of %d instance(s) - BREAK!", already) break - logger.debug("Adding %d for domain='%s'", len(peers), domain) - instances.set_total_peers(domain, peers) - logger.debug("peers()=%d - EXIT!", len(peers)) return peers diff --git a/fba/networks/peertube.py b/fba/networks/peertube.py index 3007d02..2cfa7f9 100644 --- a/fba/networks/peertube.py +++ b/fba/networks/peertube.py @@ -86,8 +86,5 @@ def fetch_peers(domain: str) -> list: logger.warning("domain='%s' causes error during API query: '%s' - SKIPPED!", domain, data['error_message']) break - logger.debug("Adding %d peers for domain='%s'", len(peers), domain) - instances.set_total_peers(domain, peers) - logger.debug("Returning peers[]='%s' - EXIT!", type(peers)) return peers -- 2.39.5