Repository: rotki/rotki

Issue:
Show what ethereum nodes are connected
## Abstract

In 1.25 we removed the "connected to own node" icon from the top navbar. Multiple users requested that this should be re-added but since now we have the feature of allowing multiples node the approach requires to list all of them. For that

1. Create a new endpoint that returns the nodes that are currently connected
2. Remove the connected to node key from the periodic resource
3. In the frontend show this information next to the list of nodes or somehow so users can check if they are connected or not. Maybe in addition would be nice to have something like before?



Discussion:
> Maybe in addition would be nice to have something like before?

No. Just show it in the settings. In a multichain world does not make sense to have a general connected/not connected icon on the top. Since the question is then connected to whom? And since we have multiple nodes per chain this becomes even more complicated.

Resolving patch:
diff --git a/rotkehlchen/chain/ethereum/manager.py b/rotkehlchen/chain/ethereum/manager.py
--- a/rotkehlchen/chain/ethereum/manager.py
+++ b/rotkehlchen/chain/ethereum/manager.py
@@ -310,6 +310,9 @@ def get_own_node_info(self) -> Optional[NodeName]:
                 return node
         return None
 
+    def get_connected_nodes(self) -> List[NodeName]:
+        return list(self.web3_mapping.keys())
+
     def attempt_connect(
             self,
             node: NodeName,
diff --git a/rotkehlchen/rotkehlchen.py b/rotkehlchen/rotkehlchen.py
--- a/rotkehlchen/rotkehlchen.py
+++ b/rotkehlchen/rotkehlchen.py
@@ -954,14 +954,14 @@ def remove_exchange(self, name: str, location: Location) -> Tuple[bool, str]:
                 self.data.db.delete_used_query_range_for_exchange(write_cursor=cursor, location=location)  # noqa: E501
         return True, ''
 
-    def query_periodic_data(self) -> Dict[str, Union[bool, Timestamp]]:
+    def query_periodic_data(self) -> Dict[str, Union[bool, List[str], Timestamp]]:
         """Query for frequently changing data"""
-        result: Dict[str, Union[bool, Timestamp]] = {}
+        result: Dict[str, Union[bool, List[str], Timestamp]] = {}
 
         if self.user_is_logged_in:
             with self.data.db.conn.read_ctx() as cursor:
                 result['last_balance_save'] = self.data.db.get_last_balance_save_time(cursor)
-                result['eth_node_connection'] = self.chain_manager.ethereum.get_own_node_web3() is not None  # noqa : E501
+                result['connected_eth_nodes'] = [node.name for node in self.chain_manager.ethereum.get_connected_nodes()]  # noqa: E501
                 result['last_data_upload_ts'] = Timestamp(self.premium_sync_manager.last_data_upload_ts)  # noqa : E501
         return result
 


Test patch:
diff --git a/rotkehlchen/tests/api/test_periodic.py b/rotkehlchen/tests/api/test_periodic.py
--- a/rotkehlchen/tests/api/test_periodic.py
+++ b/rotkehlchen/tests/api/test_periodic.py
@@ -35,6 +35,6 @@ def test_query_periodic(rotkehlchen_api_server_with_exchanges):
     result = assert_proper_response_with_result(response)
     assert len(result) == 3
     assert result['last_balance_save'] >= start_ts
-    assert result['eth_node_connection'] is False
+    assert result['connected_eth_nodes'] == []
     # Non -1 value tests for these exist in test_history.py::test_query_history_timerange
     assert result['last_data_upload_ts'] == 0