Add enhanced subscription functionality with EOSE result modes
This commit is contained in:
@@ -73,13 +73,22 @@ void on_event(cJSON* event, const char* relay_url, void* user_data) {
|
||||
}
|
||||
|
||||
// EOSE callback - called when End of Stored Events is received
|
||||
void on_eose(void* user_data) {
|
||||
void on_eose(cJSON** events, int event_count, void* user_data) {
|
||||
(void)user_data;
|
||||
time_t now = time(NULL);
|
||||
char timestamp[26];
|
||||
ctime_r(&now, timestamp);
|
||||
timestamp[24] = '\0';
|
||||
dprintf(log_fd, "[%s] 📋 EOSE received - all stored events delivered\n\n", timestamp);
|
||||
dprintf(log_fd, "[%s] 📋 EOSE received - %d events collected\n", timestamp, event_count);
|
||||
|
||||
// Log collected events if any
|
||||
for (int i = 0; i < event_count; i++) {
|
||||
cJSON* id = cJSON_GetObjectItem(events[i], "id");
|
||||
if (id && cJSON_IsString(id)) {
|
||||
dprintf(log_fd, " Event %d: %.12s...\n", i + 1, cJSON_GetStringValue(id));
|
||||
}
|
||||
}
|
||||
dprintf(log_fd, "\n");
|
||||
}
|
||||
|
||||
// Background polling thread
|
||||
@@ -270,7 +279,7 @@ void add_subscription() {
|
||||
int close_on_eose = (close_input && strcmp(close_input, "y") == 0) ? 1 : 0;
|
||||
free(close_input);
|
||||
|
||||
// Create subscription
|
||||
// Create subscription with new parameters
|
||||
nostr_pool_subscription_t* sub = nostr_relay_pool_subscribe(
|
||||
pool,
|
||||
(const char**)relay_urls,
|
||||
@@ -279,7 +288,11 @@ void add_subscription() {
|
||||
on_event,
|
||||
on_eose,
|
||||
NULL,
|
||||
close_on_eose
|
||||
close_on_eose,
|
||||
1, // enable_deduplication
|
||||
NOSTR_POOL_EOSE_FULL_SET, // result_mode
|
||||
30, // relay_timeout_seconds
|
||||
60 // eose_timeout_seconds
|
||||
);
|
||||
|
||||
// Free relay URLs
|
||||
|
||||
Reference in New Issue
Block a user