From 75c71135ba50a8f381419f1c87b7d9d8fc1833b3 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 3 Jan 2025 15:25:59 -0500 Subject: [PATCH] ssb: No longer replicate every account we hear about. --- src/ssb.ebt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ssb.ebt.c b/src/ssb.ebt.c index 240a622c..1a1ec2d8 100644 --- a/src/ssb.ebt.c +++ b/src/ssb.ebt.c @@ -148,14 +148,14 @@ static void _ebt_add_to_clock(ebt_get_clock_t* work, const char* id, int64_t val { int count = work->clock ? work->clock->count : 0; ebt_entry_t* entry = _ebt_get_entry(work->ebt, id); - if (entry->out_replicate != replicate || entry->out_receive != receive || ((replicate || receive) && entry->out != value)) + if ((replicate && !entry->out_replicate) || (receive && !entry->out_receive) || ((replicate || receive || entry->out_replicate || entry->out_receive) && entry->out != value)) { entry->out = value; - entry->out_replicate = replicate; - entry->out_receive = receive; + entry->out_replicate = entry->out_replicate || replicate; + entry->out_receive = entry->out_receive || receive; int index = tf_util_insert_index(id, count ? work->clock->entries : NULL, count, sizeof(tf_ssb_ebt_clock_entry_t), _ebt_compare_entry); - int64_t out_value = replicate ? ((value << 1) | (receive ? 0 : 1)) : -1; + int64_t out_value = entry->out_replicate ? ((value << 1) | (entry->out_receive ? 0 : 1)) : -1; if (index < count && strcmp(id, work->clock->entries[index].id) == 0) { work->clock->entries[index].value = out_value; @@ -229,7 +229,7 @@ static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, voi if (entry->in_replicate && !entry->out_replicate) { requested = tf_resize_vec(requested, (requested_count + 1) * sizeof(tf_ssb_ebt_clock_entry_t)); - requested[requested_count] = (tf_ssb_ebt_clock_entry_t) { 0 }; + requested[requested_count] = (tf_ssb_ebt_clock_entry_t) { .value = -1 }; snprintf(requested[requested_count].id, sizeof(requested[requested_count].id), "%s", entry->id); requested_count++; } @@ -246,7 +246,7 @@ static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, voi uv_mutex_lock(&work->ebt->mutex); for (int i = 0; i < requested_count; i++) { - _ebt_add_to_clock(work, requested[i].id, requested[i].value, true, true); + _ebt_add_to_clock(work, requested[i].id, requested[i].value, requested[i].value >= 0, false); } uv_mutex_unlock(&work->ebt->mutex); tf_free(requested);