From 6ee62e6575d68226512910b301511c448bfe56f7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 5 Mar 2026 15:18:13 -0400 Subject: [PATCH] Add relay state transition cause capture in poll loop --- nostr_core/core_relay_pool.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nostr_core/core_relay_pool.c b/nostr_core/core_relay_pool.c index 67297fcd..ea3691fe 100644 --- a/nostr_core/core_relay_pool.c +++ b/nostr_core/core_relay_pool.c @@ -1892,7 +1892,15 @@ int nostr_relay_pool_poll(nostr_relay_pool_t* pool, int timeout_ms) { nostr_ws_state_t state = nostr_ws_get_state(relay->ws_client); if (state != NOSTR_WS_CONNECTED) { + nostr_pool_relay_status_t prev_status = relay->status; relay->status = (state == NOSTR_WS_ERROR) ? NOSTR_POOL_RELAY_ERROR : NOSTR_POOL_RELAY_DISCONNECTED; + + // Capture transition cause for observability/debugging + if (prev_status == NOSTR_POOL_RELAY_CONNECTED || relay->last_connection_error_time == 0) { + snprintf(relay->last_connection_error, sizeof(relay->last_connection_error), + "Connection state transitioned to %d during poll", (int)state); + relay->last_connection_error_time = time(NULL); + } continue; }