Fix hash_size using first-seen-wins instead of last-seen-wins

The hashSizeMap was guarded by !hashSizeMap.has(pk), meaning the oldest
ADVERT determined a node's hash_size permanently. If a node upgraded
firmware from 1-byte to 2-byte hash prefix, the stale value persisted.

Remove the guard so newer packets overwrite older ones (last-seen-wins).
This commit is contained in:
you
2026-03-21 18:43:48 +00:00
parent 2170dd7743
commit ee58e648a6
+2 -2
View File
@@ -1087,7 +1087,7 @@ app.get('/api/nodes', (req, res) => {
try {
const d = JSON.parse(p.decoded_json || '{}');
const pk = d.pubKey || d.public_key;
if (pk && !hashSizeMap.has(pk)) {
if (pk) {
const pathByte = parseInt(p.raw_hex.slice(2, 4), 16);
hashSizeMap.set(pk, ((pathByte >> 6) & 0x3) + 1);
}
@@ -1111,7 +1111,7 @@ app.get('/api/nodes', (req, res) => {
if (p.decoded_json) {
const d = JSON.parse(p.decoded_json);
const pk = d.pubKey || d.public_key;
if (pk && !hashSizeMap.has(pk)) hashSizeMap.set(pk, hs);
if (pk) hashSizeMap.set(pk, hs);
}
}
}