]> git.mxchange.org Git - fba.git/commitdiff
Fixed:
authorRoland Häder <roland@mxchange.org>
Thu, 6 Jul 2023 07:59:05 +0000 (09:59 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 6 Jul 2023 07:59:05 +0000 (09:59 +0200)
- PeerTube's JSON response always includes mode2=following or mode2=follower
  depending on if mode=followers or mode=following is set
- this causes PeerTube instances being reported with duplicate amount of peers

fba/networks/peertube.py

index 2cfa7f9fcaef17dbc93efea5a172435a0dc0d206..7dc41cb31c4a092c0b83229462ff018c16b787d7 100644 (file)
@@ -68,13 +68,11 @@ def fetch_peers(domain: str) -> list:
                     logger.debug("Found %d record(s).", len(rows))
                     for record in rows:
                         logger.debug("record()=%d", len(record))
-                        for mode2 in ["follower", "following" ]:
-                            logger.debug("mode2='%s'", mode2)
-                            if mode2 in record and "host" in record[mode2]:
+                        for mode2 in ["follower", "following"]:
+                            logger.debug("mode=%s,mode2='%s'", mode, mode2)
+                            if mode2 in record and "host" in record[mode2] and record[mode2]["host"] != domain:
                                 logger.debug("Found mode2='%s',host='%s', adding ...", mode2, record[mode2]['host'])
                                 peers.append(record[mode2]["host"])
-                            else:
-                                logger.warning("Record from domain='%s' has no mode2='%s' or 'host' record[]='%s", domain, mode2, type(record))
 
                     if len(rows) < 100:
                         logger.debug("Reached end of JSON response, domain='%s'", domain)
@@ -86,5 +84,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("Returning peers[]='%s' - EXIT!", type(peers))
+    logger.debug("peers[%s]()=%d - EXIT!", type(peers), len(peers))
     return peers