From: Roland Häder Date: Sun, 6 Aug 2023 23:25:19 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b3011a99b77acc8b0cca678d3ce45924fb78d92a;p=fba.git Continued: - also store peer count for relays --- diff --git a/fba/commands.py b/fba/commands.py index de1c8d1..d9a00fc 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1888,6 +1888,7 @@ def fetch_relays(args: argparse.Namespace) -> int: logger.info("Checking %d relays ...", len(rows)) for row in rows: logger.debug("row[domain]='%s',row[software]='%s' ...", row["domain"], row["software"]) + peers = list() if not args.force and instances.is_recent(row["domain"]): logger.debug("row[domain]='%s' has been recently fetched - SKIPPED!", row["domain"]) continue @@ -1944,10 +1945,11 @@ def fetch_relays(args: argparse.Namespace) -> int: if domain == "": logger.debug("Empty domain after tidyup.domain() from origin='%s' - SKIPPED!", row["domain"]) continue - elif instances.is_registered(domain): - logger.debug("domain='%s' is already registered - SKIPPED!", domain) - continue - elif dict_helper.has_key(domains, "domain", domain): + elif domain not in peers: + logger.debug("Appending domain='%s' to peers list for relay='%s' ...", domain, row["domain"]) + peers.append(domain) + + if dict_helper.has_key(domains, "domain", domain): logger.debug("domain='%s' already added", domain) continue @@ -1987,10 +1989,11 @@ def fetch_relays(args: argparse.Namespace) -> int: if domain == "": logger.debug("Empty domain after tidyup.domain() from origin='%s' - SKIPPED!", row["domain"]) continue - elif instances.is_registered(domain): - logger.debug("domain='%s' is already registered - SKIPPED!", domain) - continue - elif dict_helper.has_key(domains, "domain", domain): + elif domain not in peers: + logger.debug("Appending domain='%s' to peers list for relay='%s' ...", domain, row["domain"]) + peers.append(domain) + + if dict_helper.has_key(domains, "domain", domain): logger.debug("domain='%s' already added", domain) continue @@ -2004,10 +2007,20 @@ def fetch_relays(args: argparse.Namespace) -> int: logger.debug("Updating last_instance_fetch for row[domain]='%s' ...", row["domain"]) instances.set_last_instance_fetch(row["domain"]) + + logger.info("Relay '%s' has %d peer(s) registered.", row["domain"], len(peers)) + instances.set_total_peers(row["domain"], peers) + + logger.debug("Flushing data for row[domain]='%s'", row["domain"]) instances.update_data(row["domain"]) - logger.info("Found %d domains to add ...", len(domains)) + logger.info("Checking %d domains ...", len(domains)) for row in domains: + logger.debug("row[domain]='%s',row[origin]='%s'", row["domain"], row["origin"]) + if instances.is_registered(row["domain"]): + logger.debug("row[domain]='%s' is already registered - SKIPPED!", row["domain"]) + continue + logger.info("Fetching row[domain]='%s',row[origin]='%s' ...", row["domain"], row["origin"]) federation.fetch_instances(row["domain"], row["origin"], None, inspect.currentframe().f_code.co_name)