mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-08-28 14:04:10 +00:00
fix: regional filters — proper indexed queries + frontend integration
Fixes Kpa-clawbot/meshcore-analyzer#111
This commit is contained in:
@@ -1026,15 +1026,17 @@ app.get('/api/nodes', (req, res) => {
|
||||
const regionObsIds = getObserverIdsForRegions(region);
|
||||
let regionNodeKeys = null;
|
||||
if (regionObsIds) {
|
||||
// Collect all packet hashes seen by regional observers (using byObserver index)
|
||||
const regionalHashes = new Set();
|
||||
for (const obsId of regionObsIds) {
|
||||
const obs = pktStore.byObserver.get(obsId);
|
||||
if (obs) for (const o of obs) regionalHashes.add(o.hash);
|
||||
}
|
||||
// Find node pubkeys that have at least one packet in the regional set (using _nodeHashIndex)
|
||||
regionNodeKeys = new Set();
|
||||
for (const pkt of pktStore.packets) {
|
||||
if (regionObsIds.has(pkt.observer_id)) {
|
||||
try {
|
||||
const d = JSON.parse(pkt.decoded_json || '{}');
|
||||
const pk = d.pubKey || d.public_key;
|
||||
if (pk) regionNodeKeys.add(pk);
|
||||
if (d.sender_key) regionNodeKeys.add(d.sender_key);
|
||||
} catch {}
|
||||
for (const [pubkey, hashes] of pktStore._nodeHashIndex) {
|
||||
for (const h of hashes) {
|
||||
if (regionalHashes.has(h)) { regionNodeKeys.add(pubkey); break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user