Add relay state transition cause capture in poll loop
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user