Skip to content

Commit

Permalink
update displaying reward for calculating reward epochs
Browse files Browse the repository at this point in the history
  • Loading branch information
pqv199x committed Mar 20, 2019
1 parent bb7fed7 commit 2f70b48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 9 additions & 0 deletions apis/candidates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
})
}
Expand Down
9 changes: 6 additions & 3 deletions app/components/candidates/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@
<template
slot="reward"
slot-scope="data">
{{ formatCurrencySymbol(formatNumber(data.item.reward)) }}
{{ !isNaN(data.item.reward)
? formatCurrencySymbol(formatNumber(data.item.reward)) : data.item.reward }}
</template>

<template
Expand Down Expand Up @@ -692,10 +693,12 @@ export default {
let items = []
mnRewards.data.items.map((r) => {
const reward = !isNaN(r.masternodeReward || 0)
? new BigNumber(r.masternodeReward || 0).toFixed(6) : r.masternodeReward
items.push({
epoch: r.epoch,
signNumber: r.signNumber || 0,
reward: new BigNumber(r.masternodeReward || 0).toFixed(6),
signNumber: r.signNumber ? r.signNumber : 0,
reward: reward,
createdAt: r.rewardTime ? moment(r.rewardTime).fromNow() : 'N/A',
dateTooltip: moment(r.rewardTime).format('lll'),
status: r.status
Expand Down

0 comments on commit 2f70b48

Please sign in to comment.