mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-06-06 21:51:46 +00:00
fix: hash_size uses max across all adverts, not just newest
Some nodes emit adverts with varying path byte values (e.g. 0x00 and 0x40). Taking the first/newest was unreliable. Now takes the maximum hash_size seen across all adverts for each node.
This commit is contained in:
@@ -47,15 +47,18 @@ const _hashSizeMap = new Map();
|
||||
function _rebuildHashSizeMap() {
|
||||
_hashSizeMap.clear();
|
||||
// Pass 1: from ADVERT packets (most authoritative — path byte bits 7-6)
|
||||
// packets array is sorted newest-first, so first-match = newest ADVERT
|
||||
// Take the MAXIMUM hash_size seen across all adverts (nodes can change config)
|
||||
for (const p of pktStore.packets) {
|
||||
if (p.payload_type === 4 && p.raw_hex) {
|
||||
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);
|
||||
const hs = ((pathByte >> 6) & 0x3) + 1;
|
||||
if (!_hashSizeMap.has(pk) || hs > _hashSizeMap.get(pk)) {
|
||||
_hashSizeMap.set(pk, hs);
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user