Unify media source and relay transmission with owned buffers

This commit is contained in:
evgeny committed 2026-10-22 19:11:26 +02:00
1 parent f15d53947e
commit 9b4974f02d
2 files changed
+324 -387

No files matched your search

+13 -7
View File
@@ -907,18 +907,24 @@ int topo_node_sqlite_node_get_online(sqlite3* db, uint64_t node_id) {
int topo_node_sqlite_get_ed25519_pubkey(sqlite3* db, uint64_t node_id, uint8_t pubkey_out[32])
{
if (!db || !pubkey_out) return -1;
if (!db || !pubkey_out) {
DEBUG_ERROR(DEBUG_CATEGORY_ROUTING, "get_ed25519_pubkey: invalid arguments node=%016llx", (unsigned long long)node_id);
return -1;
}
sqlite3_stmt* stmt = NULL;
if (sqlite3_prepare_v2(db, "SELECT ed25519_pubkey FROM nodes WHERE node_id=?",
-1, &stmt, NULL) != SQLITE_OK) return -1;
sqlite3_bind_int64(stmt, 1, (sqlite3_int64)node_id);
int sql_rc = sqlite3_prepare_v2(db, "SELECT ed25519_pubkey FROM nodes WHERE node_id=?", -1, &stmt, NULL);
if (sql_rc == SQLITE_OK) sql_rc = sqlite3_bind_int64(stmt, 1, (sqlite3_int64)node_id);
if (sql_rc == SQLITE_OK) sql_rc = sqlite3_step(stmt);
int rc = -1;
if (sqlite3_step(stmt) == SQLITE_ROW) {
if (sql_rc == SQLITE_ROW) {
const void* b = sqlite3_column_blob(stmt, 0);
int bytes = sqlite3_column_bytes(stmt, 0);
if (b && bytes >= 32) { uint64_t chk; memcpy(&chk, b, 8); if (chk != 0) { memcpy(pubkey_out, b, 32); rc = 0; } }
if (b && bytes == 32) { memcpy(pubkey_out, b, 32); rc = 0; }
}
sqlite3_finalize(stmt);
int final_rc = sqlite3_finalize(stmt);
if (final_rc != SQLITE_OK) rc = -1;
if (rc) DEBUG_WARN(DEBUG_CATEGORY_ROUTING, "get_ed25519_pubkey: unavailable node=%016llx sql=%d finalize=%d: %s",
(unsigned long long)node_id, sql_rc, final_rc, sqlite3_errmsg(db));
return rc;
}