diff --git a/lib/Rpc.js b/lib/Rpc.js index 648262c2e..b1406ae22 100644 --- a/lib/Rpc.js +++ b/lib/Rpc.js @@ -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);