Fix: Electrum reduced CLI noise (electrum server connections INFO/DEBUG)

This commit is contained in:
gerlofvanek
2026-01-29 20:45:54 +01:00
parent f4f3fa63f2
commit 8a86c494ee

View File

@@ -154,6 +154,7 @@ class ElectrumConnection:
except socket.timeout: except socket.timeout:
continue continue
if not data: if not data:
self._connected = False
break break
buffer += data buffer += data
while b"\n" in buffer: while b"\n" in buffer:
@@ -167,6 +168,7 @@ class ElectrumConnection:
except Exception as e: except Exception as e:
if self._listener_running and self._log: if self._listener_running and self._log:
self._log.debug(f"Electrum listener error: {e}") self._log.debug(f"Electrum listener error: {e}")
self._connected = False
break break
def _handle_message(self, message): def _handle_message(self, message):
@@ -502,6 +504,8 @@ class ElectrumServer:
self._subscribed_height_time = 0 self._subscribed_height_time = 0
self._height_callback = None self._height_callback = None
self._initial_connection_logged = False
use_tor = proxy_host is not None and proxy_port is not None use_tor = proxy_host is not None and proxy_port is not None
user_clearnet = [] user_clearnet = []
@@ -578,10 +582,17 @@ class ElectrumServer:
self._update_server_score(server, success=True, latency_ms=connect_time) self._update_server_score(server, success=True, latency_ms=connect_time)
self._last_activity = time.time() self._last_activity = time.time()
if self._log: if self._log:
self._log.info( if not self._initial_connection_logged:
f"Connected to Electrum server: {server['host']}:{server['port']} " self._log.info(
f"({self._server_version}, {connect_time:.0f}ms)" f"Connected to Electrum server: {server['host']}:{server['port']} "
) f"({self._server_version}, {connect_time:.0f}ms)"
)
self._initial_connection_logged = True
else:
self._log.debug(
f"Reconnected to Electrum server: {server['host']}:{server['port']} "
f"({connect_time:.0f}ms)"
)
if self._realtime_enabled: if self._realtime_enabled:
self._start_realtime_listener() self._start_realtime_listener()
self._start_keepalive() self._start_keepalive()
@@ -817,7 +828,7 @@ class ElectrumServer:
for attempt in range(2): for attempt in range(2):
if self._connection is None or not self._connection.is_connected(): if self._connection is None or not self._connection.is_connected():
self.connect() self.connect()
elif (time.time() - self._last_activity) > 10: elif (time.time() - self._last_activity) > 60:
if not self._check_connection_health(): if not self._check_connection_health():
self._retry_on_failure() self._retry_on_failure()
try: try:
@@ -844,7 +855,7 @@ class ElectrumServer:
for attempt in range(2): for attempt in range(2):
if self._connection is None or not self._connection.is_connected(): if self._connection is None or not self._connection.is_connected():
self.connect() self.connect()
elif (time.time() - self._last_activity) > 10: elif (time.time() - self._last_activity) > 60:
if not self._check_connection_health(): if not self._check_connection_health():
self._retry_on_failure() self._retry_on_failure()
try: try: