Compare commits

...

2 Commits

Author SHA1 Message Date
36226b01cd ssb: Manage new message handling from the new EBT code.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 22m57s
2025-01-03 17:04:38 -05:00
da31f9cadd cleanup: get/set sent clock is now unused. 2025-01-03 16:56:04 -05:00
4 changed files with 8 additions and 29 deletions

View File

@ -279,7 +279,6 @@ typedef struct _tf_ssb_connection_t
int32_t tunnel_request_number; int32_t tunnel_request_number;
tf_ssb_blob_wants_t blob_wants; tf_ssb_blob_wants_t blob_wants;
bool sent_clock;
int32_t ebt_request_number; int32_t ebt_request_number;
tf_ssb_ebt_t* ebt; tf_ssb_ebt_t* ebt;
@ -3888,16 +3887,6 @@ void tf_ssb_verify_strip_and_store_message(tf_ssb_t* ssb, JSValue value, tf_ssb_
} }
} }
bool tf_ssb_connection_get_sent_clock(tf_ssb_connection_t* connection)
{
return connection->sent_clock;
}
void tf_ssb_connection_set_sent_clock(tf_ssb_connection_t* connection, bool sent_clock)
{
connection->sent_clock = sent_clock;
}
int32_t tf_ssb_connection_get_ebt_request_number(tf_ssb_connection_t* connection) int32_t tf_ssb_connection_get_ebt_request_number(tf_ssb_connection_t* connection)
{ {
return connection->ebt_request_number; return connection->ebt_request_number;

View File

@ -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_replicate = true;
entry->in_receive = (sequence & 1) == 0; 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_FreeCString(context, author);
JS_FreeValue(context, key); 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); uv_mutex_lock(&ebt->mutex);
ebt_entry_t* entry = _ebt_get_entry(ebt, id); ebt_entry_t* entry = _ebt_get_entry(ebt, id);
entry->in = tf_max(entry->in, sequence); 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); uv_mutex_unlock(&ebt->mutex);
} }

View File

@ -925,20 +925,6 @@ int32_t tf_ssb_connection_get_ebt_request_number(tf_ssb_connection_t* connection
*/ */
void tf_ssb_connection_set_ebt_request_number(tf_ssb_connection_t* connection, int32_t request_number); void tf_ssb_connection_set_ebt_request_number(tf_ssb_connection_t* connection, int32_t request_number);
/**
** Get whether the EBT clock has been sent for a connection.
** @param connection An SHS connection.
** @return True if the clock has been sent.
*/
bool tf_ssb_connection_get_sent_clock(tf_ssb_connection_t* connection);
/**
** Set the EBT clock sent state for a connection.
** @param connection An SHS connection.
** @param sent_clock Whether the clock has been sent.
*/
void tf_ssb_connection_set_sent_clock(tf_ssb_connection_t* connection, bool sent_clock);
/** /**
** Get the JS class ID of the SSB connection class. ** Get the JS class ID of the SSB connection class.
** @return The class ID ** @return The class ID

View File

@ -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); 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; 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); _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); tf_free(clock);
} }