relay_pool: skip reconnect attempts in publish_async

This commit is contained in:
Your Name
2026-03-05 11:01:21 -04:00
parent 481bf3158d
commit ea84795911
+11 -6
View File
@@ -1480,8 +1480,13 @@ int nostr_relay_pool_publish_async(
}
}
if (relay && ensure_relay_connection(relay) == 0) {
// Send EVENT message
int relay_connected = 0;
if (relay && relay->ws_client) {
relay_connected = (nostr_ws_get_state(relay->ws_client) == NOSTR_WS_CONNECTED);
}
if (relay_connected) {
// Send EVENT message only on already-connected relays
if (nostr_relay_send_event(relay->ws_client, event) >= 0) {
relay->stats.events_published++;
success_count++;
@@ -1489,7 +1494,7 @@ int nostr_relay_pool_publish_async(
// If send failed and we have a callback, notify immediately
if (callback && op) {
callback(relay_urls[i], event_id, 0, "Failed to send event to relay", user_data);
// Remove this relay from the pending operation
int remaining = remove_relay_from_publish_operation(op, relay_urls[i]);
if (remaining == 0) {
@@ -1499,10 +1504,10 @@ int nostr_relay_pool_publish_async(
}
}
} else {
// Connection failed - notify callback immediately if provided
// Relay not currently connected - publish is skipped; reconnection is handled by poll loop
if (callback && op) {
callback(relay_urls[i], event_id, 0, "Failed to connect to relay", user_data);
callback(relay_urls[i], event_id, 0, "Relay not connected; publish skipped", user_data);
// Remove this relay from the pending operation
int remaining = remove_relay_from_publish_operation(op, relay_urls[i]);
if (remaining == 0) {