mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
fixes, seems stable enough for now
This commit is contained in:
parent
31c41b2673
commit
fa38063685
@ -1889,6 +1889,8 @@ const parseOrchestrator = async function (reqAddr) {
|
|||||||
orchestratorObj = orchestratorObj.transcoder;
|
orchestratorObj = orchestratorObj.transcoder;
|
||||||
// Not found
|
// Not found
|
||||||
if (!orchestratorObj) {
|
if (!orchestratorObj) {
|
||||||
|
console.log("Pushing null orchestrator " + reqAddr + " @ " + now);
|
||||||
|
orchestratorCache.push({id: reqAddr, lastGet: now });
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
orchestratorObj.lastGet = now;
|
orchestratorObj.lastGet = now;
|
||||||
@ -2537,7 +2539,7 @@ const getScoreAtMonthYear = async function (month, year) {
|
|||||||
// Else get it and cache it
|
// Else get it and cache it
|
||||||
const url = "https://leaderboard-serverless.vercel.app/api/aggregated_stats?since=" + startTime + "&until=" + endTime;
|
const url = "https://leaderboard-serverless.vercel.app/api/aggregated_stats?since=" + startTime + "&until=" + endTime;
|
||||||
console.log("Getting new Orchestrator scores for " + year + "-" + month + " @ " + url);
|
console.log("Getting new Orchestrator scores for " + year + "-" + month + " @ " + url);
|
||||||
await https.get(url, (res) => {
|
return https.get(url, (res) => {
|
||||||
let body = "";
|
let body = "";
|
||||||
res.on("data", (chunk) => {
|
res.on("data", (chunk) => {
|
||||||
body += chunk;
|
body += chunk;
|
||||||
@ -2565,6 +2567,7 @@ const getScoreAtMonthYear = async function (month, year) {
|
|||||||
}
|
}
|
||||||
// Also update monthly stats
|
// Also update monthly stats
|
||||||
mutateTestScoresToDB(scoreObj, month, year);
|
mutateTestScoresToDB(scoreObj, month, year);
|
||||||
|
return scoreObj;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@ const Address = (obj) => {
|
|||||||
thisInfo = thisAddr;
|
thisInfo = thisAddr;
|
||||||
hasENS = true;
|
hasENS = true;
|
||||||
// Check timeout
|
// Check timeout
|
||||||
if (now - thisAddr.timestamp < 86400000) {
|
if (now - thisAddr.timestamp < 3600000) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Is outdated
|
// Is outdated
|
||||||
|
@ -10,15 +10,18 @@ const WinnerMonth = (obj) => {
|
|||||||
const livepeer = useSelector((state) => state.livepeerstate);
|
const livepeer = useSelector((state) => state.livepeerstate);
|
||||||
const [thisScores, setThisScores] = useState(null);
|
const [thisScores, setThisScores] = useState(null);
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(() => {
|
||||||
if (!obj.data.testScores) {
|
const setScore = async() => {
|
||||||
const freshScore = await getOrchestratorScores(obj.data.year, obj.data.month);
|
if (!obj.data.testScores) {
|
||||||
if (freshScore) {
|
const freshScore = await getOrchestratorScores(obj.data.year, obj.data.month);
|
||||||
setThisScores(freshScore);
|
if (freshScore) {
|
||||||
|
setThisScores(freshScore);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setThisScores(obj.data.testScores);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setThisScores(obj.data.testScores);
|
|
||||||
}
|
}
|
||||||
|
setScore();
|
||||||
}, [obj.data.testScores]);
|
}, [obj.data.testScores]);
|
||||||
|
|
||||||
const getName = (address) => {
|
const getName = (address) => {
|
||||||
@ -137,16 +140,38 @@ const WinnerMonth = (obj) => {
|
|||||||
let ticketIdx2 = orchList.length - 1;
|
let ticketIdx2 = orchList.length - 1;
|
||||||
let largestIdx = 0;
|
let largestIdx = 0;
|
||||||
let largestValue = 0;
|
let largestValue = 0;
|
||||||
|
let thisVal = null;
|
||||||
// Find current O with most ticket wins in Eth
|
// Find current O with most ticket wins in Eth
|
||||||
while (ticketIdx2 >= 0) {
|
while (ticketIdx2 >= 0) {
|
||||||
const currentOrch = orchList[ticketIdx2];
|
const currentOrch = orchList[ticketIdx2];
|
||||||
const thisVal = (currentOrch.sum || currentOrch.totalStake);
|
thisVal = currentOrch.sum;
|
||||||
|
if (!thisVal) {
|
||||||
|
ticketIdx2 -= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (thisVal > largestValue) {
|
if (thisVal > largestValue) {
|
||||||
largestIdx = ticketIdx2;
|
largestIdx = ticketIdx2;
|
||||||
largestValue = thisVal;
|
largestValue = thisVal;
|
||||||
}
|
}
|
||||||
ticketIdx2 -= 1;
|
ticketIdx2 -= 1;
|
||||||
}
|
}
|
||||||
|
// Else try to sort by stake
|
||||||
|
if (!thisVal) {
|
||||||
|
ticketIdx2 = orchList.length - 1;
|
||||||
|
while (ticketIdx2 >= 0) {
|
||||||
|
const currentOrch = orchList[ticketIdx2];
|
||||||
|
thisVal = currentOrch.totalStake;
|
||||||
|
if (!thisVal) {
|
||||||
|
ticketIdx2 -= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (thisVal > largestValue) {
|
||||||
|
largestIdx = ticketIdx2;
|
||||||
|
largestValue = thisVal;
|
||||||
|
}
|
||||||
|
ticketIdx2 -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Push current biggest list
|
// Push current biggest list
|
||||||
sortedList.push(orchList[largestIdx]);
|
sortedList.push(orchList[largestIdx]);
|
||||||
// Remove from list
|
// Remove from list
|
||||||
@ -165,7 +190,7 @@ const WinnerMonth = (obj) => {
|
|||||||
while (ticketIdx >= 0) {
|
while (ticketIdx >= 0) {
|
||||||
const thisTicket = obj.data.winningTicketsReceived[ticketIdx];
|
const thisTicket = obj.data.winningTicketsReceived[ticketIdx];
|
||||||
ticketIdx -= 1;
|
ticketIdx -= 1;
|
||||||
if ((thisTicket.sum / obj.data.winningTicketsReceivedSum) < 0.04) {
|
if ((thisTicket.sum / obj.data.winningTicketsReceivedSum) < 0.03) {
|
||||||
otherSum += thisTicket.sum;
|
otherSum += thisTicket.sum;
|
||||||
} else {
|
} else {
|
||||||
pieList.push({
|
pieList.push({
|
||||||
|
@ -101,8 +101,8 @@ const Winner = (obj) => {
|
|||||||
<div className="rowAlignLeft" >
|
<div className="rowAlignLeft" >
|
||||||
<h3>Fees</h3>
|
<h3>Fees</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="rowAlignLeft" >
|
<div className="rowAlignRight" >
|
||||||
<h4>{obj.thisEarnings.sum.toFixed(4)} Eth</h4>
|
<span>{obj.thisEarnings.sum.toFixed(4)} Eth</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="rowAlignRight" >
|
<div className="rowAlignRight" >
|
||||||
<span>({((obj.thisEarnings.sum / obj.totalEarnings) * 100).toFixed(2)} %)</span>
|
<span>({((obj.thisEarnings.sum / obj.totalEarnings) * 100).toFixed(2)} %)</span>
|
||||||
@ -114,8 +114,8 @@ const Winner = (obj) => {
|
|||||||
<div className="rowAlignLeft" >
|
<div className="rowAlignLeft" >
|
||||||
<h3>Stake</h3>
|
<h3>Stake</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="rowAlignLeft" >
|
<div className="rowAlignRight" >
|
||||||
<h4>{obj.thisStake.totalStake.toFixed(4)} LPT</h4>
|
<span>{obj.thisStake.totalStake.toFixed(2)} LPT</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="rowAlignRight" >
|
<div className="rowAlignRight" >
|
||||||
<span>({((obj.thisStake.totalStake / obj.totalStake) * 100).toFixed(2)} %)</span>
|
<span>({((obj.thisStake.totalStake / obj.totalStake) * 100).toFixed(2)} %)</span>
|
||||||
|
@ -43,13 +43,13 @@ const EventButtonAddress = (obj) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Lookup current info in cache only if this addr has a mapped ENS domain
|
// Lookup current info in cache only if this addr has a mapped ENS domain
|
||||||
if (thisDomain && thisDomain.domain && !hasRefreshed) {
|
if (livepeer.ensInfoMapping && thisDomain && thisDomain.domain && !hasRefreshed) {
|
||||||
for (const thisAddr of livepeer.ensInfoMapping) {
|
for (const thisAddr of livepeer.ensInfoMapping) {
|
||||||
if (thisAddr.domain === thisDomain.domain) {
|
if (thisAddr.domain === thisDomain.domain) {
|
||||||
thisInfo = thisAddr;
|
thisInfo = thisAddr;
|
||||||
hasENS = true;
|
hasENS = true;
|
||||||
// Check timeout
|
// Check timeout
|
||||||
if (now - thisAddr.timestamp < 86400000) {
|
if (now - thisAddr.timestamp < 3600000) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Is outdated
|
// Is outdated
|
||||||
|
@ -32,8 +32,6 @@ export default (state = {
|
|||||||
blockchains: [],
|
blockchains: [],
|
||||||
thisOrchestrator: null,
|
thisOrchestrator: null,
|
||||||
selectedOrchestrator: null,
|
selectedOrchestrator: null,
|
||||||
ensInfoMapping: [],
|
|
||||||
ensDomainMapping: [],
|
|
||||||
winningTickets: [],
|
winningTickets: [],
|
||||||
orchScores: [],
|
orchScores: [],
|
||||||
monthlyStats: [],
|
monthlyStats: [],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user