From d95448181a031841b33c199ff178538c41f28a67 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Sun, 8 May 2022 17:37:45 +0200 Subject: [PATCH] Fix round details to DB --- backend/src/routes/livepeer.js | 40 ++++++++++++++++++++++------------ src/components/RoundViewer.js | 11 +++++----- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/backend/src/routes/livepeer.js b/backend/src/routes/livepeer.js index 86e297c..252d094 100644 --- a/backend/src/routes/livepeer.js +++ b/backend/src/routes/livepeer.js @@ -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 + }); } } diff --git a/src/components/RoundViewer.js b/src/components/RoundViewer.js index dbe3467..95ce7a1 100644 --- a/src/components/RoundViewer.js +++ b/src/components/RoundViewer.js @@ -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 ?

- Has {obj.round.mintableTokens.toFixed(2)} mintable tokens + Has {parseFloat(obj.round.mintableTokens).toFixed(2)} mintable tokens

: null } @@ -62,7 +61,7 @@ const Round = (obj) => { obj.round.volumeEth && obj.round.volumeUsd && obj.round.volumeEth > 0 && obj.round.volumeUsd > 0 ?

- 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)}$)

: null } @@ -70,7 +69,7 @@ const Round = (obj) => { obj.round.totalSupply && obj.round.totalActiveStake && obj.round.totalSupply > 0 && obj.round.totalActiveStake > 0 ?

- 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)}%)

: null } @@ -78,7 +77,7 @@ const Round = (obj) => { obj.round.newStake && obj.round.newStake > 0 ?

- {obj.round.newStake.toFixed(2)} LPT new stake + {parseFloat(obj.round.newStake).toFixed(2)} LPT new stake

: null } @@ -86,7 +85,7 @@ const Round = (obj) => { obj.round.movedStake && obj.round.movedStake > 0 ?

- {obj.round.movedStake.toFixed(2)} LPT stake moved around + {parseFloat(obj.round.movedStake).toFixed(2)} LPT stake moved around

: null }