- src/db_sync: LMDB replaced with SQLite (separate tables per instance: db_sync_name_id) TTL index (author, timestamp), WAL mode, per-instance peers/timers opaque DB_SYNC_INSTANCE* handle, insert callback, select API new fields: author_signature, delivered_peers, delivery_chain transport: etcp_api direct P2P (was etcp_router) - src/db_sync.h: user-oriented API docs, multi-instance lifecycle - lib/Makefile.am: liblmdb sources removed - lib/sqlite3.c+h: SQLite amalgamation added - topo_node: LMDB→SQLite (src/topo_node_sqlite.c moved from chatgui) - chatgui: real db_sync.c replaces db_sync_stub.c chat_core: db_sync_insert_signed + dual-write insert callback utun_node: db_sync_init/destroy replaces chat_sync_init/destroy CMakeLists: stubs removed, real db_sync.c added
84 lines
2.6 KiB
C
84 lines
2.6 KiB
C
/*
|
|
* chat_core.h — центральный API чата в потоке uasync
|
|
*
|
|
* Все DB-операции и сетевые функции выполняются в uasync-потоке.
|
|
* GUI вызывает chat_core_submit_message() через gui_bridge_post_uasync().
|
|
*/
|
|
|
|
#ifndef CHAT_CORE_H
|
|
#define CHAT_CORE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
struct sqlite3;
|
|
struct UTUN_INSTANCE;
|
|
|
|
/* ── Жизненный цикл ── */
|
|
|
|
int chat_core_init(struct UTUN_INSTANCE* inst, const char* db_path);
|
|
void chat_core_destroy(struct UTUN_INSTANCE* inst);
|
|
|
|
/* ── Отправка сообщения (GUI → uasync) ── */
|
|
|
|
struct chat_msg_submit {
|
|
char channel_id[64];
|
|
char content_type[32];
|
|
uint8_t* data;
|
|
uint32_t data_len;
|
|
uint64_t timestamp;
|
|
};
|
|
|
|
void chat_core_submit_message(struct chat_msg_submit* req);
|
|
|
|
/* ── Stubs for chat_sync compatibility (todo: remove when chat_sync is fully replaced) ── */
|
|
|
|
void chat_core_mark_sent(const char* ch_id, uint64_t ts, uint64_t dh, uint64_t peer_id);
|
|
void chat_core_ttl_delete(const char* ch_id, uint64_t node_id, uint64_t cutoff_us);
|
|
|
|
/* ── DB-операции (оставлены для интроспекции) ── */
|
|
|
|
int chat_core_list_channels(uint8_t* buf, size_t buf_size, size_t* out_len);
|
|
int chat_core_list_peers(const char* ch_id, uint8_t* buf, size_t buf_size, size_t* out_len);
|
|
int chat_core_load_nodeinfo(uint64_t node_id, uint8_t* buf, size_t buf_size, size_t* out_len);
|
|
|
|
/* ── Подключение к пиру (из invite-ссылки) ── */
|
|
|
|
struct chat_invite {
|
|
uint64_t channel_id;
|
|
uint64_t node_id;
|
|
uint8_t pubkey[32];
|
|
uint8_t* addrs_data;
|
|
int addr_count;
|
|
};
|
|
|
|
void chat_core_connect_from_invite(struct chat_invite* inv);
|
|
|
|
/* ── Создание канала (GUI → uasync) ── */
|
|
|
|
struct chat_channel_create {
|
|
char channel_id[64];
|
|
char name[128];
|
|
uint64_t owner_node_id;
|
|
int is_dm;
|
|
uint8_t x25519_pubkey[32];
|
|
uint8_t x25519_privkey[32];
|
|
uint8_t ed25519_pubkey[32];
|
|
uint8_t ed25519_privkey[32];
|
|
uint8_t signature[64];
|
|
};
|
|
|
|
void chat_core_create_channel(struct chat_channel_create* req);
|
|
void chat_core_create_channel_trampoline(void* arg);
|
|
|
|
/* ── Утилиты ── */
|
|
|
|
void chat_core_set_my_node_id(uint64_t node_id);
|
|
void chat_core_update_my_name(const char* name);
|
|
void chat_core_update_my_name_trampoline(void* arg);
|
|
|
|
/* Трамплин для gui_bridge_post_uasync (GUI → uasync) */
|
|
void chat_core_submit_trampoline(void* arg);
|
|
|
|
#endif /* CHAT_CORE_H */
|