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++) {
if (roundCache[idx].number == roundNumber){
wasCached = true;
roundCache[idx].lengthBlocks = thisRoundObj.lengthBlocks;
roundCache[idx].startBlock = thisRoundObj.startBlock;
roundCache[idx].endBlock = thisRoundObj.endBlock;
roundCache[idx].mintableTokens = thisRoundObj.mintableTokens;
@ -1498,20 +1497,19 @@ const getRoundInfo = async function (roundNumber) {
// FindAndUpdate
if (!CONF_DISABLE_DB) {
// Update DB entry
const doc = await MonthlyStat.findOneAndUpdate({
const doc = await Round.findOneAndUpdate({
number: roundNumber
}, {
lengthBlocks: roundObj.lengthBlocks,
startBlock: roundObj.startBlock,
endBlock: roundObj.endBlock,
mintableTokens: roundObj.mintableTokens,
volumeEth: roundObj.volumeETH,
volumeUsd: roundObj.volumeUSD,
totalActiveStake: roundObj.totalActiveStake,
totalSupply: roundObj.totalSupply,
participationRate: roundObj.participationRate,
movedStake: roundObj.movedStake,
newStake: roundObj.newStake
startBlock: thisRoundObj.startBlock,
endBlock: thisRoundObj.endBlock,
mintableTokens: thisRoundObj.mintableTokens,
volumeEth: thisRoundObj.volumeETH,
volumeUsd: thisRoundObj.volumeUSD,
totalActiveStake: thisRoundObj.totalActiveStake,
totalSupply: thisRoundObj.totalSupply,
participationRate: thisRoundObj.participationRate,
movedStake: thisRoundObj.movedStake,
newStake: thisRoundObj.newStake
}, {
new: true
});
@ -1520,7 +1518,6 @@ const getRoundInfo = async function (roundNumber) {
number: doc.number,
transactionHash: doc.transactionHash,
blockNumber: doc.blockNumber,
lengthBlocks: doc.lengthBlocks,
startBlock: doc.startBlock,
endBlock: doc.endBlock,
mintableTokens: doc.mintableTokens,
@ -1533,6 +1530,21 @@ const getRoundInfo = async function (roundNumber) {
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";
import { useDispatch, useSelector } from 'react-redux';
import { Popover } from '@mantine/core';
import { getOrchestratorByDelegator } from "../util/livepeer";
const Round = (obj) => {
const [opened, setOpened] = useState(false);
@ -54,7 +53,7 @@ const Round = (obj) => {
obj.round.mintableTokens && obj.round.mintableTokens > 0 ?
<div className="row">
<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>
</div> : null
}
@ -62,7 +61,7 @@ const Round = (obj) => {
obj.round.volumeEth && obj.round.volumeUsd && obj.round.volumeEth > 0 && obj.round.volumeUsd > 0 ?
<div className="row">
<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>
</div> : null
}
@ -70,7 +69,7 @@ const Round = (obj) => {
obj.round.totalSupply && obj.round.totalActiveStake && obj.round.totalSupply > 0 && obj.round.totalActiveStake > 0 ?
<div className="row">
<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>
</div> : null
}
@ -78,7 +77,7 @@ const Round = (obj) => {
obj.round.newStake && obj.round.newStake > 0 ?
<div className="row">
<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>
</div> : null
}
@ -86,7 +85,7 @@ const Round = (obj) => {
obj.round.movedStake && obj.round.movedStake > 0 ?
<div className="row">
<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>
</div> : null
}