From 36226b01cd9dcd0529955380d932f24164039dd5 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 3 Jan 2025 17:04:38 -0500 Subject: [PATCH] ssb: Manage new message handling from the new EBT code. --- src/ssb.ebt.c | 8 ++++++++ src/ssb.rpc.c | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ssb.ebt.c b/src/ssb.ebt.c index 1a1ec2d8..88256749 100644 --- a/src/ssb.ebt.c +++ b/src/ssb.ebt.c @@ -114,6 +114,10 @@ void tf_ssb_ebt_receive_clock(tf_ssb_ebt_t* ebt, JSContext* context, JSValue clo entry->in_replicate = true; entry->in_receive = (sequence & 1) == 0; } + if (!entry->in_receive) + { + tf_ssb_connection_remove_new_message_request(ebt->connection, author); + } JS_FreeCString(context, author); JS_FreeValue(context, key); } @@ -298,5 +302,9 @@ void tf_ssb_ebt_set_messages_sent(tf_ssb_ebt_t* ebt, const char* id, int64_t seq uv_mutex_lock(&ebt->mutex); ebt_entry_t* entry = _ebt_get_entry(ebt, id); entry->in = tf_max(entry->in, sequence); + if (entry->in == entry->out && (tf_ssb_connection_get_flags(ebt->connection) & k_tf_ssb_connect_flag_one_shot) == 0) + { + tf_ssb_connection_add_new_message_request(ebt->connection, id, tf_ssb_connection_get_ebt_request_number(ebt->connection), false); + } uv_mutex_unlock(&ebt->mutex); } diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index 7004681c..b2f03710 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -957,10 +957,6 @@ static void _tf_ssb_rpc_ebt_replicate_send_messages(tf_ssb_connection_t* connect int32_t request_number = tf_ssb_connection_get_ebt_request_number(connection); bool live = (tf_ssb_connection_get_flags(connection) & k_tf_ssb_connect_flag_one_shot) == 0; _tf_ssb_connection_send_history_stream(connection, request_number, entry->id, entry->value, false, live, false); - if (live) - { - tf_ssb_connection_add_new_message_request(connection, entry->id, request_number, false); - } } tf_free(clock); }