member_sync/topo_sqlite: add proto byte to address serialization
- _compute_bucket_hash: SELECT protocol, write proto byte - _member_get_items: SELECT protocol, write proto byte - _member_apply_items: consume proto byte in skip calculation - topo_node_sqlite_channel_peers_all: SELECT protocol, write proto byte All 5 writers and 5 readers now consistently include protocol byte.
This commit is contained in:
1 parent
8023f6ee70
commit
5d23f461a7
2 files changed
+23
-14
No files matched your search
@@ -382,7 +382,7 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
|
||||
|
||||
sqlite3_stmt* ast = NULL;
|
||||
snprintf(sql, sizeof(sql),
|
||||
"SELECT family, socket_id, address, port FROM node_addresses"
|
||||
"SELECT family, socket_id, protocol, address, port FROM node_addresses"
|
||||
" WHERE node_id=? AND addr_type=0 LIMIT 16");
|
||||
if (sqlite3_prepare_v2(db, sql, -1, &ast, NULL) != SQLITE_OK) continue;
|
||||
sqlite3_bind_int64(ast, 1, (sqlite3_int64)node_id);
|
||||
@@ -391,14 +391,16 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
|
||||
while (sqlite3_step(ast) == SQLITE_ROW && addr_cnt < 255) {
|
||||
int family = sqlite3_column_int(ast, 0);
|
||||
int sock_id = sqlite3_column_int(ast, 1);
|
||||
int proto = sqlite3_column_int(ast, 2);
|
||||
int ip_len = (family == 4) ? 4 : 16;
|
||||
const uint8_t* ip = (const uint8_t*)sqlite3_column_blob(ast, 2);
|
||||
uint16_t port = (uint16_t)sqlite3_column_int(ast, 3);
|
||||
const uint8_t* ip = (const uint8_t*)sqlite3_column_blob(ast, 3);
|
||||
uint16_t port = (uint16_t)sqlite3_column_int(ast, 4);
|
||||
if (!ip) continue;
|
||||
if (off + 1 + 1 + ip_len + 2 > buf_sz) { sqlite3_finalize(ast); sqlite3_finalize(stmt); return -2; }
|
||||
if (off + 1 + 1 + 1 + ip_len + 2 > buf_sz) { sqlite3_finalize(ast); sqlite3_finalize(stmt); return -2; }
|
||||
if (addr_cnt == 0) addr_start = off;
|
||||
buf[off++] = (uint8_t)family;
|
||||
buf[off++] = (uint8_t)sock_id;
|
||||
buf[off++] = (uint8_t)proto;
|
||||
memcpy(buf + off, ip, (size_t)ip_len); off += (size_t)ip_len;
|
||||
buf[off++] = (uint8_t)((port >> 8) & 0xFF);
|
||||
buf[off++] = (uint8_t)(port & 0xFF);
|
||||
|
||||
Reference in new issue
Block a user