inschpektor
Version:
An IOTA neighbor manager for your node.
24 lines (21 loc) • 796 B
JavaScript
const NODE_STATE = require('../state/node.state');
const NOTIFICATION_SERVICE = require('../service/notification.service');
const GLOBALS = require('../state/globals');
const isAllowedToSendNotification = require('./gatekepper');
const assertPremiumNeighborsSynced = () => {
if (
NODE_STATE.currentNeighbors &&
NODE_STATE.currentNeighbors
.filter(n => n.latestSolidSubtangleMilestoneIndex)
.filter(
n =>
n.latestSolidSubtangleMilestoneIndex >=
NODE_STATE.currentOwnNodeInfo.latestMilestoneIndex -
GLOBALS.MAX_MILESTONES_BEHIND_BEFORE_UNSYNCED
).length > 0 &&
isAllowedToSendNotification()
) {
NOTIFICATION_SERVICE.sendNotification('A neighbor is out of sync!');
}
};
module.exports = assertPremiumNeighborsSynced;