Fix round details to DB

This commit is contained in:
Marco van Dijk 2022-05-08 17:37:45 +02:00
parent e6af7cc0dc
commit d95448181a
2 changed files with 31 additions and 20 deletions

View File

@ -1482,7 +1482,6 @@ const getRoundInfo = async function (roundNumber) {
for (var idx = 0; idx < roundCache.length; idx++) { for (var idx = 0; idx < roundCache.length; idx++) {
if (roundCache[idx].number == roundNumber){ if (roundCache[idx].number == roundNumber){
wasCached = true; wasCached = true;
roundCache[idx].lengthBlocks = thisRoundObj.lengthBlocks;
roundCache[idx].startBlock = thisRoundObj.startBlock; roundCache[idx].startBlock = thisRoundObj.startBlock;
roundCache[idx].endBlock = thisRoundObj.endBlock; roundCache[idx].endBlock = thisRoundObj.endBlock;
roundCache[idx].mintableTokens = thisRoundObj.mintableTokens; roundCache[idx].mintableTokens = thisRoundObj.mintableTokens;
@ -1498,20 +1497,19 @@ const getRoundInfo = async function (roundNumber) {
// FindAndUpdate // FindAndUpdate
if (!CONF_DISABLE_DB) { if (!CONF_DISABLE_DB) {
// Update DB entry // Update DB entry
const doc = await MonthlyStat.findOneAndUpdate({ const doc = await Round.findOneAndUpdate({
number: roundNumber number: roundNumber
}, { }, {
lengthBlocks: roundObj.lengthBlocks, startBlock: thisRoundObj.startBlock,
startBlock: roundObj.startBlock, endBlock: thisRoundObj.endBlock,
endBlock: roundObj.endBlock, mintableTokens: thisRoundObj.mintableTokens,
mintableTokens: roundObj.mintableTokens, volumeEth: thisRoundObj.volumeETH,
volumeEth: roundObj.volumeETH, volumeUsd: thisRoundObj.volumeUSD,
volumeUsd: roundObj.volumeUSD, totalActiveStake: thisRoundObj.totalActiveStake,
totalActiveStake: roundObj.totalActiveStake, totalSupply: thisRoundObj.totalSupply,
totalSupply: roundObj.totalSupply, participationRate: thisRoundObj.participationRate,
participationRate: roundObj.participationRate, movedStake: thisRoundObj.movedStake,
movedStake: roundObj.movedStake, newStake: thisRoundObj.newStake
newStake: roundObj.newStake
}, { }, {
new: true new: true
}); });
@ -1520,7 +1518,6 @@ const getRoundInfo = async function (roundNumber) {
number: doc.number, number: doc.number,
transactionHash: doc.transactionHash, transactionHash: doc.transactionHash,
blockNumber: doc.blockNumber, blockNumber: doc.blockNumber,
lengthBlocks: doc.lengthBlocks,
startBlock: doc.startBlock, startBlock: doc.startBlock,
endBlock: doc.endBlock, endBlock: doc.endBlock,
mintableTokens: doc.mintableTokens, mintableTokens: doc.mintableTokens,
@ -1533,6 +1530,21 @@ const getRoundInfo = async function (roundNumber) {
newStake: doc.newStake newStake: doc.newStake
}); });
} }
return ({
number: doc.number,
transactionHash: doc.transactionHash,
blockNumber: doc.blockNumber,
startBlock: doc.startBlock,
endBlock: doc.endBlock,
mintableTokens: doc.mintableTokens,
volumeETH: doc.volumeETH,
volumeUSD: doc.volumeUSD,
totalActiveStake: doc.totalActiveStake,
totalSupply: doc.totalSupply,
participationRate: doc.participationRate,
movedStake: doc.movedStake,
newStake: doc.newStake
});
} }
} }

View File

@ -4,7 +4,6 @@ import {
} from "../actions/livepeer"; } from "../actions/livepeer";
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { Popover } from '@mantine/core'; import { Popover } from '@mantine/core';
import { getOrchestratorByDelegator } from "../util/livepeer";
const Round = (obj) => { const Round = (obj) => {
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
@ -54,7 +53,7 @@ const Round = (obj) => {
obj.round.mintableTokens && obj.round.mintableTokens > 0 ? obj.round.mintableTokens && obj.round.mintableTokens > 0 ?
<div className="row"> <div className="row">
<p className="darkText" style={{ overflowWrap: 'break-word' }}> <p className="darkText" style={{ overflowWrap: 'break-word' }}>
Has {obj.round.mintableTokens.toFixed(2)} mintable tokens Has {parseFloat(obj.round.mintableTokens).toFixed(2)} mintable tokens
</p> </p>
</div> : null </div> : null
} }
@ -62,7 +61,7 @@ const Round = (obj) => {
obj.round.volumeEth && obj.round.volumeUsd && obj.round.volumeEth > 0 && obj.round.volumeUsd > 0 ? obj.round.volumeEth && obj.round.volumeUsd && obj.round.volumeEth > 0 && obj.round.volumeUsd > 0 ?
<div className="row"> <div className="row">
<p className="darkText" style={{ overflowWrap: 'break-word' }}> <p className="darkText" style={{ overflowWrap: 'break-word' }}>
A volume of {obj.round.volumeEth.toFixed(2)} Eth ({obj.round.volumeUsd.toFixed(2)}$) A volume of {parseFloat(obj.round.volumeEth).toFixed(2)} Eth ({parseFloat(obj.round.volumeUsd).toFixed(2)}$)
</p> </p>
</div> : null </div> : null
} }
@ -70,7 +69,7 @@ const Round = (obj) => {
obj.round.totalSupply && obj.round.totalActiveStake && obj.round.totalSupply > 0 && obj.round.totalActiveStake > 0 ? obj.round.totalSupply && obj.round.totalActiveStake && obj.round.totalSupply > 0 && obj.round.totalActiveStake > 0 ?
<div className="row"> <div className="row">
<p className="darkText" style={{ overflowWrap: 'break-word' }}> <p className="darkText" style={{ overflowWrap: 'break-word' }}>
A total supply of {obj.round.totalSupply.toFixed(2)} LPT, of which {obj.round.totalActiveStake.toFixed(2)} is staked ({(obj.round.participationRate * 100).toFixed(2)}%) A total supply of {parseFloat(obj.round.totalSupply).toFixed(2)} LPT, of which {parseFloat(obj.round.totalActiveStake).toFixed(2)} is staked ({(parseFloat(obj.round.participationRate) * 100).toFixed(2)}%)
</p> </p>
</div> : null </div> : null
} }
@ -78,7 +77,7 @@ const Round = (obj) => {
obj.round.newStake && obj.round.newStake > 0 ? obj.round.newStake && obj.round.newStake > 0 ?
<div className="row"> <div className="row">
<p className="darkText" style={{ overflowWrap: 'break-word' }}> <p className="darkText" style={{ overflowWrap: 'break-word' }}>
{obj.round.newStake.toFixed(2)} LPT new stake {parseFloat(obj.round.newStake).toFixed(2)} LPT new stake
</p> </p>
</div> : null </div> : null
} }
@ -86,7 +85,7 @@ const Round = (obj) => {
obj.round.movedStake && obj.round.movedStake > 0 ? obj.round.movedStake && obj.round.movedStake > 0 ?
<div className="row"> <div className="row">
<p className="darkText" style={{ overflowWrap: 'break-word' }}> <p className="darkText" style={{ overflowWrap: 'break-word' }}>
{obj.round.movedStake.toFixed(2)} LPT stake moved around {parseFloat(obj.round.movedStake).toFixed(2)} LPT stake moved around
</p> </p>
</div> : null </div> : null
} }