From 2f70b4840c18f6572ce26f4213e4630004ede08f Mon Sep 17 00:00:00 2001 From: Vu Pham Date: Wed, 20 Mar 2019 15:48:51 +0700 Subject: [PATCH] update displaying reward for calculating reward epochs --- apis/candidates.js | 9 +++++++++ app/components/candidates/View.vue | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apis/candidates.js b/apis/candidates.js index 3d118c3f..c9c4cabd 100644 --- a/apis/candidates.js +++ b/apis/candidates.js @@ -630,6 +630,11 @@ router.get('/:candidate/:owner/getRewards', [ const candidate = req.params.candidate const owner = req.params.owner + + const latestBlockNumber = await web3.eth.getBlockNumber() + const latestCheckpoint = latestBlockNumber - (latestBlockNumber % parseInt(config.get('blockchain.epoch'))) + const currentEpoch = (parseInt(latestCheckpoint / config.get('blockchain.epoch')) + 1).toString() + let limit = (req.query.limit) ? parseInt(req.query.limit) : 100 const page = parseInt(req.query.page) || 1 let skip @@ -670,6 +675,10 @@ router.get('/:candidate/:owner/getRewards', [ if (!r.reward) { r.rewardTime = mn.epochCreatedAt || '' } + if (currentEpoch - r.epoch < 2) { + r.masternodeReward = '-' + r.signNumber = '-' + } return r }) } diff --git a/app/components/candidates/View.vue b/app/components/candidates/View.vue index 2707ef49..5be822ca 100644 --- a/app/components/candidates/View.vue +++ b/app/components/candidates/View.vue @@ -262,7 +262,8 @@