Release fixture history gate after verified member synchronization
This commit is contained in:
1 parent
de1da1c9b1
commit
9f36fb0ddd
1 file changed
+15
-1
@@ -12,6 +12,7 @@
|
||||
#include "../src/chat/chat_core.h"
|
||||
#include "../src/chat/chat_attachment.h"
|
||||
#include "../src/chat/member_sync.h"
|
||||
#include "../src/chat/db_sync.h"
|
||||
#include "../src/chat/chat_setting.h"
|
||||
#include "../src/routing_layer/topo_node_sqlite.h"
|
||||
#include "../src/routing_layer/topo_group.h"
|
||||
@@ -80,6 +81,15 @@ static int start_node(struct media_test* t, int index) {
|
||||
return t->nodes[index] ? utun_instance_init(t->nodes[index]) : -1;
|
||||
}
|
||||
|
||||
/* Фикстура создаёт канал напрямую, поэтому сама снимает gate после реального Merkle round. */
|
||||
static void members_ready(uint64_t peer, const char* channel, int result, void* arg) {
|
||||
struct UTUN_INSTANCE* inst = arg;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "encrypted fixture: members verified local=%llu peer=%llu channel=%s result=%d",
|
||||
(unsigned long long)inst->node_id, (unsigned long long)peer, channel, result);
|
||||
struct DB_SYNC_INSTANCE* sync = db_sync_instance_find(inst, GROUP);
|
||||
if (result == MT_OK && sync) db_sync_instance_set_gated(sync, 0);
|
||||
}
|
||||
|
||||
static int setup(struct media_test* t) {
|
||||
for (int i = 0; i < NODES; i++) {
|
||||
struct UTUN_INSTANCE* inst = t->nodes[i];
|
||||
@@ -100,7 +110,11 @@ static int setup(struct media_test* t) {
|
||||
if (member_sync_put(inst, CHANNEL, t->ids[j], t->keys[j].public_key, t->ed[j], join, ts,
|
||||
NULL, 0, info, tags, adm_sig, 0, 0, certificate) < 0) return -1;
|
||||
}
|
||||
if (i != S) member_sync_start(inst, t->ids[S], CHANNEL, NULL, NULL);
|
||||
}
|
||||
for (int i = 0; i < NODES; i++) {
|
||||
if (i == S) continue;
|
||||
if (member_sync_start(t->nodes[i], t->ids[S], CHANNEL, members_ready, t->nodes[i]) < 0 ||
|
||||
member_sync_start(t->nodes[S], t->ids[i], CHANNEL, members_ready, t->nodes[S]) < 0) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user