Skip to content

Commit

Permalink
hot fix reward too big
Browse files Browse the repository at this point in the history
  • Loading branch information
khaihkd committed Nov 7, 2018
1 parent 034c889 commit ac54b69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/src/queues/rewardAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ consumer.task = async function (job, done) {
balance = new BigNumber(balance)

let account = await db.Account.findOne({ hash: address })
let newBalance = new BigNumber(account.balance).plus(balance)
let newBalance = new BigNumber(account.balance).plus(balance.multipliedBy(10 ** 18))

account.balance = newBalance.toString()
account.balanceNumber = newBalance.toNumber()
Expand Down
5 changes: 3 additions & 2 deletions server/src/queues/rewardValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ consumer.task = async function (job, done) {
let endBlock = parseInt(epoch) * config.get('BLOCK_PER_EPOCH')
let startBlock = endBlock - config.get('BLOCK_PER_EPOCH') + 1

let totalReward = new BigNumber(config.get('REWARD')).multipliedBy(10 ** 18)
let totalReward = new BigNumber(config.get('REWARD'))
let validatorRewardPercent = new BigNumber(config.get('MASTER_NODE_REWARD_PERCENT'))
let foundationRewardPercent = new BigNumber(config.get('FOUNDATION_REWARD_PERCENT'))
let voterRewardPercent = new BigNumber(config.get('VOTER_REWARD_PERCENT'))
Expand Down Expand Up @@ -111,14 +111,15 @@ consumer.task = async function (job, done) {
.priority('normal').removeOnComplete(true).save()

let lockBalance = await validatorContract.methods.getVoterCap(validator.address, ownerValidator).call()
lockBalance = new BigNumber(lockBalance)
await rewardValidator.push({
epoch: epoch,
startBlock: startBlock,
endBlock: endBlock,
address: ownerValidator,
validator: validator.address,
reason: 'MasterNode',
lockBalance: new BigNumber(lockBalance).toString(),
lockBalance: lockBalance.dividedBy(10 ** 18).toString(),
reward: reward4validator.toString(),
rewardTime: timestamp,
signNumber: validator.signNumber
Expand Down
2 changes: 2 additions & 0 deletions server/src/queues/rewardVoter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ consumer.task = async function (job, done) {

let totalVoterCap = await validatorContract.methods.getCandidateCap(validator).call()
totalVoterCap = new BigNumber(totalVoterCap)
totalVoterCap = totalVoterCap.dividedBy(10 ** 18)
let listVoters = []
let voterMap = voters.map(async (voter) => {
voter = voter.toString().toLowerCase()
let voterCap = await validatorContract.methods.getVoterCap(validator, voter).call()
voterCap = new BigNumber(voterCap)
voterCap = voterCap.dividedBy(10 ** 18)
listVoters.push({
address: voter,
balance: voterCap
Expand Down

0 comments on commit ac54b69

Please sign in to comment.