]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 23 Jul 2023 17:30:13 +0000 (19:30 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 23 Jul 2023 17:30:13 +0000 (19:30 +0200)
- better check if no peers has further been added

fba/networks/misskey.py

index ec35833e1599f20bd859ae31bdb1ddf0d50ddeb5..c2541113faca0f347395db0ead1bf1da73b482de 100644 (file)
@@ -86,7 +86,7 @@ def fetch_peers(domain: str) -> list:
 
         rows = fetched["json"]
 
-        logger.debug("rows(%d)[]='%s'", len(rows), type(rows))
+        logger.debug("rows(%d)[]='%s',step=%d", len(rows), type(rows), step)
         if len(rows) == 0:
             logger.debug("Returned zero bytes, domain='%s' - BREAK!", domain)
             break
@@ -97,7 +97,7 @@ def fetch_peers(domain: str) -> list:
             logger.debug("Raising offset by step=%d", step)
             offset = offset + step
 
-        already = 0
+        added = 0
         logger.debug("rows(%d))[]='%s'", len(rows), type(rows))
         for row in rows:
             logger.debug("row()=%d", len(row))
@@ -112,14 +112,15 @@ def fetch_peers(domain: str) -> list:
                 continue
             elif row["host"] in peers:
                 logger.debug("Not adding row[host]='%s', already found - SKIPPED!", row['host'])
-                already = already + 1
                 continue
 
             logger.debug("Adding peer: row[host]='%s'", row['host'])
+            added = added + 1
             peers.append(row["host"])
 
-        if already == len(rows):
-            logger.debug("Host returned same set of %d instance(s) - BREAK!", already)
+        logger.debug("added=%d,rows()=%d", added, len(rows))
+        if added == 0:
+            logger.debug("Host returned already added (%d) peers - BREAK!", len(rows))
             break
 
     logger.debug("peers()=%d - EXIT!", len(peers))