ssb: sequence: Sequential 32-bit integer starting at 1.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m2s

This commit is contained in:
2025-06-11 20:12:23 -04:00
parent 2a6789063e
commit a1f1eb34d5
13 changed files with 89 additions and 84 deletions

View File

@ -16,7 +16,7 @@
#include <time.h>
static void _tf_ssb_connection_send_history_stream(
tf_ssb_connection_t* connection, int32_t request_number, const char* author, int64_t sequence, bool keys, bool live, bool end_request);
tf_ssb_connection_t* connection, int32_t request_number, const char* author, int32_t sequence, bool keys, bool live, bool end_request);
static void _tf_ssb_rpc_send_peers_exchange(tf_ssb_connection_t* connection);
static void _tf_ssb_rpc_start_delete_blobs(tf_ssb_t* ssb, int delay_ms);
static void _tf_ssb_rpc_start_delete_feeds(tf_ssb_t* ssb, int delay_ms);
@ -863,13 +863,13 @@ typedef struct _tf_ssb_connection_send_history_stream_t
{
int32_t request_number;
char author[k_id_base64_len];
int64_t sequence;
int32_t sequence;
bool keys;
bool live;
bool end_request;
bool out_finished;
int64_t out_max_sequence_seen;
int32_t out_max_sequence_seen;
char** out_messages;
int out_messages_count;
} tf_ssb_connection_send_history_stream_t;
@ -890,8 +890,8 @@ static void _tf_ssb_connection_send_history_stream_work(tf_ssb_connection_t* con
"sequence < ?3 ORDER BY sequence",
-1, &statement, NULL) == SQLITE_OK)
{
if (sqlite3_bind_text(statement, 1, request->author, -1, NULL) == SQLITE_OK && sqlite3_bind_int64(statement, 2, request->sequence) == SQLITE_OK &&
sqlite3_bind_int64(statement, 3, request->sequence + k_max) == SQLITE_OK)
if (sqlite3_bind_text(statement, 1, request->author, -1, NULL) == SQLITE_OK && sqlite3_bind_int(statement, 2, request->sequence) == SQLITE_OK &&
sqlite3_bind_int(statement, 3, request->sequence + k_max) == SQLITE_OK)
{
JSMallocFunctions funcs = { 0 };
tf_get_js_malloc_functions(&funcs);
@ -902,7 +902,7 @@ static void _tf_ssb_connection_send_history_stream_work(tf_ssb_connection_t* con
while ((r = sqlite3_step(statement)) == SQLITE_ROW)
{
JSValue message = JS_UNDEFINED;
request->out_max_sequence_seen = sqlite3_column_int64(statement, 3);
request->out_max_sequence_seen = sqlite3_column_int(statement, 3);
JSValue formatted = tf_ssb_format_message(context, (const char*)sqlite3_column_text(statement, 0), (const char*)sqlite3_column_text(statement, 1),
sqlite3_column_int64(statement, 3), sqlite3_column_double(statement, 4), (const char*)sqlite3_column_text(statement, 5),
@ -997,7 +997,7 @@ static void _tf_ssb_connection_send_history_stream_callback(tf_ssb_connection_t*
}
static void _tf_ssb_connection_send_history_stream(
tf_ssb_connection_t* connection, int32_t request_number, const char* author, int64_t sequence, bool keys, bool live, bool end_request)
tf_ssb_connection_t* connection, int32_t request_number, const char* author, int32_t sequence, bool keys, bool live, bool end_request)
{
if (tf_ssb_connection_is_connected(connection) && !tf_ssb_is_shutting_down(tf_ssb_connection_get_ssb(connection)) && !tf_ssb_connection_is_closing(connection))
{
@ -1036,8 +1036,8 @@ static void _tf_ssb_rpc_createHistoryStream(
JSValue live = JS_GetPropertyStr(context, arg, "live");
bool is_keys = JS_IsUndefined(keys) || JS_ToBool(context, keys) > 0;
bool is_live = JS_ToBool(context, live) > 0 && (tf_ssb_connection_get_flags(connection) & k_tf_ssb_connect_flag_one_shot) == 0;
int64_t sequence = 0;
JS_ToInt64(context, &sequence, seq);
int32_t sequence = 0;
JS_ToInt32(context, &sequence, seq);
const char* author = JS_ToCString(context, id);
_tf_ssb_connection_send_history_stream(connection, -request_number, author, sequence, is_keys, is_live, true);
@ -1258,7 +1258,7 @@ typedef struct _invite_use_t
;
uint8_t private_key[512];
char previous_id[64];
int64_t previous_sequence;
int32_t previous_sequence;
char host[256];
int port;
@ -1780,7 +1780,7 @@ typedef struct _invite_t
int32_t request_number;
bool accepted;
char previous_id[256];
int64_t previous_sequence;
int32_t previous_sequence;
char* message;
} invite_t;
@ -1882,7 +1882,7 @@ static void _tf_ssb_rpc_invite_use(tf_ssb_connection_t* connection, uint8_t flag
tf_ssb_connection_run_work(connection, _tf_ssb_rpc_invite_use_work, _tf_ssb_rpc_invite_use_after_work, work);
}
static void _tf_ssb_rpc_message_added_callback(tf_ssb_t* ssb, const char* author, int64_t sequence, const char* id, void* user_data)
static void _tf_ssb_rpc_message_added_callback(tf_ssb_t* ssb, const char* author, int32_t sequence, const char* id, void* user_data)
{
tf_ssb_connection_t* connections[256];
int count = tf_ssb_get_connections(ssb, connections, tf_countof(connections));