some nodes are spamming map reports at a high rate. we don't need them
This commit is contained in:
17
src/mqtt.js
17
src/mqtt.js
@ -406,6 +406,21 @@ client.on("message", async (topic, message) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// find an existing map with duplicate information created in the last 60 seconds
|
||||||
|
const existingDuplicateMapReport = await prisma.mapReport.findFirst({
|
||||||
|
where: {
|
||||||
|
node_id: envelope.packet.from,
|
||||||
|
long_name: mapReport.longName,
|
||||||
|
short_name: mapReport.shortName,
|
||||||
|
created_at: {
|
||||||
|
gte: new Date(Date.now() - 60000), // created in the last 60 seconds
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// create map report if no duplicates found
|
||||||
|
if(!existingDuplicateMapReport){
|
||||||
await prisma.mapReport.create({
|
await prisma.mapReport.create({
|
||||||
data: {
|
data: {
|
||||||
node_id: envelope.packet.from,
|
node_id: envelope.packet.from,
|
||||||
@ -424,6 +439,8 @@ client.on("message", async (topic, message) => {
|
|||||||
num_online_local_nodes: mapReport.numOnlineLocalNodes,
|
num_online_local_nodes: mapReport.numOnlineLocalNodes,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user