fix: remove stale peers_* CREATE TABLE from chat_core, drop ORDER BY node_RTT
chat_core_ensure_channel_ready() had a duplicate CREATE TABLE peers_* with OLD schema (no node_RTT, node_type, connected). Since it was called from 4 places WITHOUT topo_node_sqlite_channel_put() first, the old schema was created first, and IF NOT EXISTS in the new DDL was a no-op. Removed the entire old block. Only topo_node_sqlite_channel_put() now creates peers_* tables with the full schema. Also removed ORDER BY p.node_RTT from get_public_peers/get_local_peers — ordering not needed for sequential connect attempts.
This commit is contained in:
1 parent
8facce46ac
commit
be258eea4d
2 files changed
+2
-30
No files matched your search
@@ -634,32 +634,6 @@ void chat_core_ensure_channel_ready(const char* ch_id) {
|
||||
|
||||
char tbl_msg[80]; msg_table_name(ch_id, tbl_msg, sizeof(tbl_msg));
|
||||
|
||||
char tbl_peers[80]; peers_table_name(ch_id, tbl_peers, sizeof(tbl_peers));
|
||||
char sql[512];
|
||||
snprintf(sql, sizeof(sql),
|
||||
"CREATE TABLE IF NOT EXISTS \"%s\" ("
|
||||
" node_id INTEGER PRIMARY KEY," /* уникальный ID узла (64-bit) */
|
||||
" x25519_pubkey BLOB NOT NULL," /* X25519 публичный ключ (32 байта) */
|
||||
" ed25519_pubkey BLOB," /* Ed25519 публичный ключ (32 байта) — верификация join_sig/update_sig */
|
||||
" join_sig BLOB," /* Ed25519 подпись присоединения (PEERS_JOIN_SIG_SIZE=64).
|
||||
signed: ch_x25519(32)||ch_ed25519(32)||node_id(8 LE)||x25519(32)||join_ts(8 LE) */
|
||||
" join_ts INTEGER DEFAULT 0," /* NTP timestamp подписи join_sig — защита от replay */
|
||||
" update_sig BLOB," /* Ed25519 подпись обновления userinfo (PEERS_UPDATE_SIG_SIZE=64).
|
||||
signed: join_sig(64)||update_ts(8 LE)||userinfo(NUL-terminated) */
|
||||
" update_ts INTEGER DEFAULT 0," /* NTP timestamp подписи update_sig */
|
||||
" userinfo TEXT NOT NULL DEFAULT ''," /* JSON с информацией о пользователе: {"name":"<display_name>"}.
|
||||
извлекается через json_flat_get(userinfo, "name", ...) */
|
||||
" creator_sig BLOB," /* Ed25519 подпись создателя (PEERS_JOIN_SIG_SIZE=64).
|
||||
в CHANNEL_INFO_RESP ставится join_sig инвайтера, иначе NULL (заглушка) */
|
||||
" comment TEXT," /* произвольная заметка (пока не используется в логике) */
|
||||
" joined_at INTEGER DEFAULT (unixepoch())" /* NTP timestamp добавления записи в таблицу */
|
||||
")", tbl_peers);
|
||||
db_exec(sql);
|
||||
|
||||
// Migration: rename old 'name' column to 'userinfo' (match server schema)
|
||||
snprintf(sql, sizeof(sql), "ALTER TABLE \"%s\" RENAME COLUMN name TO userinfo", tbl_peers);
|
||||
sqlite3_exec(g_cc.db, sql, NULL, NULL, NULL);
|
||||
|
||||
uint64_t ch_hash = 0;
|
||||
{ const uint8_t* chd = (const uint8_t*)ch_id; size_t chl = strlen(ch_id); uint8_t sh[32]; SHA256(chd, chl, sh); memcpy(&ch_hash, sh, 8); }
|
||||
struct DB_SYNC_INSTANCE* si = db_sync_instance_add(g_cc.inst, tbl_msg, ch_hash);
|
||||
|
||||
Reference in new issue
Block a user