Fix key timeout

This commit is contained in:
Marco van Dijk 2023-11-03 12:32:02 +01:00
parent d3afd739ae
commit 67781976cc

View File

@ -291,21 +291,33 @@ const onOrchUpdate = async function (id, obj, tag, region, livepeer_regions) {
} }
// Remove expired stuff // Remove expired stuff
for (const [id, obj] of Object.entries(newInstance.probedFrom)) { Object.keys(newInstance.probedFrom).forEach((key) => {
if (now - obj.lastTime > CONF_KEY_EXPIRY) { if (
newInstance.probedFrom[id] = null; !newInstance.probedFrom[key] ||
!newInstance.probedFrom[key].lastTime ||
now - newInstance.probedFrom[key].lastTime > CONF_KEY_EXPIRY
) {
delete newInstance.probedFrom[key];
} }
});
Object.keys(newInstance.regions).forEach((key) => {
if (
!newInstance.regions[key] ||
!newInstance.regions[key].lastTime ||
now - newInstance.regions[key].lastTime > CONF_KEY_EXPIRY
) {
delete newInstance.regions[key];
} }
for (const [id, obj] of Object.entries(newInstance.regions)) { });
if (now - obj.lastTime > CONF_KEY_EXPIRY) { Object.keys(newInstance.livepeer_regions).forEach((key) => {
newInstance.regions[id] = null; if (
} !newInstance.livepeer_regions[key] ||
} !newInstance.livepeer_regions[key].lastTime ||
for (const [id, obj] of Object.entries(newInstance.livepeer_regions)) { now - newInstance.livepeer_regions[key].lastTime > CONF_KEY_EXPIRY
if (now - obj.lastTime > CONF_KEY_EXPIRY) { ) {
newInstance.livepeer_regions[id] = null; delete newInstance.livepeer_regions[key];
}
} }
});
// Set last times for instance info // Set last times for instance info
newInstance.probedFrom[tag] = { newInstance.probedFrom[tag] = {
@ -436,7 +448,9 @@ const updateScore = async function (address) {
const newRTR = instance.round_trip_time / instance.seg_duration; const newRTR = instance.round_trip_time / instance.seg_duration;
let latitude = null; let latitude = null;
let longitude = null; let longitude = null;
for (const [resolvedTarget, instance] of Object.entries(thisInstances)) { for (const [resolvedTarget, instance] of Object.entries(
thisInstances
)) {
if (instance.livepeer_regions[region]) { if (instance.livepeer_regions[region]) {
latitude = instance.latitude; latitude = instance.latitude;
longitude = instance.longitude; longitude = instance.longitude;