Skip to content

Commit

Permalink
Fix reward calculations since voters will return 0 and goof up the
Browse files Browse the repository at this point in the history
calculations
  • Loading branch information
alexlyp committed Feb 24, 2016
1 parent b3cd6da commit 8a58c40
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/Rpc.js
Expand Up @@ -112,18 +112,19 @@ Rpc.getBlock = function(hash, cb) {
}

// Number of voters for the block in question
var voters = info.result.voters;
var votersProportion = info.result.voters == 0 ? 1 : info.result.voters / 5;

// Calculate the 3 different portions of block reward
var work = Math.round(base * workProportion / 10 * voters / 5);
var stake = Math.round(base * stakeProportion / 10 * voters / 5);
var tax = Math.round(base * taxProportion / 10 * voters / 5);

var work = base * workProportion / 10 * votersProportion;
var stake = base * stakeProportion / 10 * votersProportion;
var tax = base * taxProportion / 10 * votersProportion;

// If block height is below mainnet voting height, leave out stake
if (info.result.height < 4096) {
info.result.reward = (work + tax) / bitcore.util.COIN;
info.result.reward = Math.round(work + tax) / bitcore.util.COIN;
} else {
info.result.reward = (work + stake + tax) / bitcore.util.COIN;
info.result.reward = Math.round(work + stake + tax) / bitcore.util.COIN;
}
}
return cb(err,info.result);
Expand Down

0 comments on commit 8a58c40

Please sign in to comment.