]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 21 Nov 2023 16:23:41 +0000 (17:23 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 21 Nov 2023 16:23:41 +0000 (17:23 +0100)
- added last_response_time to templates
- moved cookie clearing to proper place (?)

daemon.py
fba/http/federation.py
templates/views/infos.html
templates/views/list.html

index ff68610febec2415e866f67ff29c73c54be17251..5ee0181a81ef5db068dcd13c4d8942548908a8d7 100755 (executable)
--- a/daemon.py
+++ b/daemon.py
@@ -447,7 +447,7 @@ def infos(request: Request, domain: str):
     tformat = config.get("timestamp_format")
     instance = dict()
     for key in domain_data.keys():
-        if key in ["last_nodeinfo", "last_blocked", "first_seen", "last_updated", "last_instance_fetch", "last_response_time"] and isinstance(domain_data[key], float):
+        if key in ["last_nodeinfo", "last_blocked", "first_seen", "last_updated", "last_instance_fetch" and isinstance(domain_data[key], float):
             # Timestamps
             instance[key] = datetime.utcfromtimestamp(domain_data[key]).strftime(tformat)
         else:
index 0fd572039a88a578ad54bc912bfc5d31876e0f07..c17e52d749033d74023cbe95a258c90c93770a6c 100644 (file)
@@ -107,6 +107,9 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         logger.debug("Invoking instances.set_total_peerlist(%s,%d) ...", domain, len(peerlist))
         instances.set_total_peers(domain, peerlist)
 
+    logger.debug("Invoking cookies.clear(%s) ...", domain)
+    cookies.clear(domain)
+
     logger.debug("peerlist[]='%s'", type(peerlist))
     if peerlist is None:
         logger.warning("Cannot fetch peers: domain='%s',software='%s'", domain, software)
@@ -115,15 +118,18 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
             logger.debug("Flushing updates for domain='%s' ...", domain)
             instances.update(domain)
 
-        logger.debug("Invoking cookies.clear(%s) ...", domain)
-        cookies.clear(domain)
-
         _DEPTH = _DEPTH - 1
         logger.debug("EXIT!")
         return
     elif len(peerlist) == 0:
-        logger.debug("domain='%s',software='%s' has an empty peer list returned - EXIT!", domain, software)
+        logger.info("domain='%s' returned an empty peer list.", domain)
+
+        if instances.has_pending(domain):
+            logger.debug("Flushing updates for domain='%s' ...", domain)
+            instances.update(domain)
+
         _DEPTH = _DEPTH - 1
+        logger.debug("domain='%s',software='%s' has an empty peer list returned - EXIT!", domain, software)
         return
 
     logger.info("Checking %d instance(s) from domain='%s',software='%s',depth=%d ...", len(peerlist), domain, software, _DEPTH)
@@ -171,9 +177,6 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
                 logger.debug("Adding instance='%s',domain='%s',command='%s',_DEPTH=%d ...", instance, domain, command, _DEPTH)
                 instances.add(instance, domain, command)
 
-    logger.debug("Invoking cookies.clear(%s) ...", domain)
-    cookies.clear(domain)
-
     logger.debug("Checking if domain='%s' has pending updates ...", domain)
     if instances.has_pending(domain):
         logger.debug("Flushing updates for domain='%s' ...", domain)
index 0eb57d8efde998ebf1044dfb97e1ef0b567a7ca2..274360f988f87fe070d97c19adcea46f4394f0a4 100644 (file)
         <td>{{instance['total_blocks']}}</td>
     </tr>
 
+    <tr>
+        <td>Last response time:</td>
+        <td>{{'%0.2f'|format(instance['last_response_time']|float)}}</td>
+    </tr>
+
     <tr>
         <td>Obfuscated blocks:</td>
         <td>{{instance['obfuscated_blocks']}}</td>
index 1f5ff96b3a6f5f2b5c2437b5b36d86e6507748bf..1e48ebdbf3a36b7862891b08e5f3277cf1916788 100644 (file)
@@ -44,6 +44,7 @@
             <th>Command</th>
             <th>Total peers</th>
             <th>Total blocks</th>
+            <th>Response time</th>
             <th>First added</th>
             <th>Last updated</th>
         </thead>
@@ -74,6 +75,7 @@
                 <td><code>{{row['command']}}</code></td>
                 <td>{{row['total_peers']}}</td>
                 <td>{{row['total_blocks']}}</td>
+                <td>{{'%0.2f'|format(row['last_response_time']|float)}}</td>
                 <td>{{row['first_seen']}}</td>
                 <td>{{row['last_updated']}}</td>
             </tr>