This commit is contained in:
Marco van Dijk 2023-11-03 02:48:42 +01:00
parent 045b18a973
commit 9b63d72b09

View File

@ -96,7 +96,7 @@ const getEnsDomain = async function (addr) {
const now = new Date().getTime(); const now = new Date().getTime();
const cached = ensDomainCache[addr]; const cached = ensDomainCache[addr];
if (cached && now - cached.timestamp < CONF_TIMEOUT_ENS_DOMAIN) { if (cached && now - cached.timestamp < CONF_TIMEOUT_ENS_DOMAIN) {
return cached.domain || cached.address; return cached.domain ? cached.domain : cached.address
} }
// Refresh cause not cached or stale // Refresh cause not cached or stale
let ensDomain; let ensDomain;
@ -130,7 +130,7 @@ const getEnsDomain = async function (addr) {
ensObj.timestamp ensObj.timestamp
); );
ensDomainCache[addr] = ensObj; ensDomainCache[addr] = ensObj;
return ensObj.domain || ensObj.address; return ensObj.domain ? ensObj.domain : ensObj.address
}; };
/* /*
@ -192,16 +192,17 @@ const onOrchUpdate = async function (id, obj, tag, region, livepeer_regions) {
while (!ensDomain) { while (!ensDomain) {
ensDomain = await getEnsDomain(id); ensDomain = await getEnsDomain(id);
} }
obj.name = ensDomain;
// Retrieve entry to update or init it // Retrieve entry to update or init it
let newObj = orchCache[id]; let newObj = orchCache[id];
if (!newObj) { if (!newObj) {
newObj = { newObj = {
name: "", name: obj.name,
regionalStats: {}, regionalStats: {},
instances: {}, instances: {},
leaderboardResults: { lastTime: now }, leaderboardResults: { lastTime: now },
}; };
}else{
newObj.name = ensDomain;
} }
// Find region entry or init it // Find region entry or init it
let newRegion = newObj.regionalStats[tag]; let newRegion = newObj.regionalStats[tag];