fix(chat): node online status race, WELCOME peer_needed off-by-one, JOIN missing proto byte
- node_put/node_update_verified: set online=1 on INSERT (nodes created when conn is UP) - channel_peers_all: fix peer_needed calculation (atl byte was missing) - cs_send_channel_join: add proto byte to address serialization matching all parsers
This commit is contained in:
1 parent
38eb51c679
commit
f476188566
18 files changed
+431
-24
No files matched your search
@@ -116,8 +116,8 @@ int topo_node_sqlite_node_put(sqlite3* db, struct TOPO_GROUPS* groups, struct TO
|
||||
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
if (sqlite3_prepare_v2(db,
|
||||
"INSERT INTO nodes(node_id, name, x25519_pubkey, ed25519_pubkey, last_seen_at)"
|
||||
" VALUES(?,?,?,?,?)"
|
||||
"INSERT INTO nodes(node_id, name, x25519_pubkey, ed25519_pubkey, last_seen_at, online)"
|
||||
" VALUES(?,?,?,?,?,1)"
|
||||
" ON CONFLICT(node_id) DO UPDATE SET"
|
||||
" name=CASE WHEN excluded.name != '' THEN excluded.name ELSE nodes.name END, x25519_pubkey=excluded.x25519_pubkey,"
|
||||
" ed25519_pubkey=excluded.ed25519_pubkey, last_seen_at=excluded.last_seen_at,\n"
|
||||
@@ -273,8 +273,8 @@ int topo_node_sqlite_node_update_verified(sqlite3* db, uint64_t node_id,
|
||||
if (!db || !x25519 || !ed25519) return -1;
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
if (sqlite3_prepare_v2(db,
|
||||
"INSERT INTO nodes(node_id, name, x25519_pubkey, ed25519_pubkey, created_at, update_ts)"
|
||||
" VALUES(?,?,?,?,?,?)"
|
||||
"INSERT INTO nodes(node_id, name, x25519_pubkey, ed25519_pubkey, created_at, update_ts, online)"
|
||||
" VALUES(?,?,?,?,?,?,1)"
|
||||
" ON CONFLICT(node_id) DO UPDATE SET"
|
||||
" name=CASE WHEN excluded.name IS NOT NULL AND excluded.name != ''"
|
||||
" THEN excluded.name ELSE nodes.name END,"
|
||||
@@ -409,7 +409,7 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
|
||||
sqlite3_finalize(ast);
|
||||
|
||||
uint8_t flags = (join_sig && join_ts) ? PEERS_FLAG_HAS_JOIN : 0;
|
||||
size_t peer_needed = 8 + 32 + 32 + 1 + (flags & PEERS_FLAG_HAS_JOIN ? 64+8 : 0) + 64 + 8 + 1 + (size_t)nl + 1 + (size_t)atl + 64 + 1;
|
||||
size_t peer_needed = 8 + 32 + 32 + 1 + (flags & PEERS_FLAG_HAS_JOIN ? 64+8 : 0) + 64 + 8 + 1 + (size_t)nl + 1 + 1 + (size_t)atl + 64;
|
||||
size_t addr_sz = off - addr_start;
|
||||
if (addr_cnt > 0) {
|
||||
if (off + peer_needed > buf_sz) { sqlite3_finalize(stmt); return -2; }
|
||||
|
||||
Reference in new issue
Block a user