From edae264ec4d9f2edcbaeecd1702e19be6cee4a04 Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Wed, 29 Apr 2020 00:40:24 +0200 Subject: [PATCH] simplified number of peers check on monitorRPKI --- src/monitors/monitorRPKI.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/monitors/monitorRPKI.js b/src/monitors/monitorRPKI.js index b446c56..1015d92 100644 --- a/src/monitors/monitorRPKI.js +++ b/src/monitors/monitorRPKI.js @@ -45,23 +45,9 @@ export default class MonitorRPKI extends Monitor { squashAlerts = (alerts) => { - const matchedMessages = alerts.map(alert => alert.matchedMessage); - const matchPerPrefix = {}; - const prefixesOut = []; + const peers = [...new Set(alerts.map(alert => alert.matchedMessage.peer))].length; - for (let m of matchedMessages) { // Get the number of peers that triggered the alert for each prefix - matchPerPrefix[m.prefix] = matchPerPrefix[m.prefix] || []; - matchPerPrefix[m.prefix].push(m.peer); - } - - for (let p in matchPerPrefix) { // Check if any of the prefixes went above the thresholdMinPeers - const peers = [...new Set(matchPerPrefix[p])]; - if (peers.length >= this.thresholdMinPeers) { - prefixesOut.push(p); - } - } - - if (prefixesOut.length > 0) { + if (peers >= this.thresholdMinPeers) { const firstAlert = alerts[0]; const message = firstAlert.matchedMessage; const extra = firstAlert.extra;