Skip to content

Commit

Permalink
support circulationSupply with the rewards.longtermReserve config option
Browse files Browse the repository at this point in the history
  • Loading branch information
hackmod committed Mar 19, 2019
1 parent 641781c commit 92357b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion public/js/controllers/StatsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ angular.module('BlocksApp').controller('StatsController', function($stateParams,
dataset.push(d);
}
});
} else if (k !== 'height') {
} else if (k !== 'height' && k != 'circulatingSupply') {
var d = { _id: k, amount: res.data[k] };
dataset.push(d);
}
Expand Down
8 changes: 6 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ var getBlock = function(req, res) {
*/
var getTotalSupply = function(req, res) {
var act;
if (req.params.act && ['total', 'totalSupply', 'genesisAlloc', 'minerRewards', 'uncleRewards'].indexOf(req.params.act) > -1) {
if (req.params.act && ['total', 'totalSupply', 'circulatingSupply', 'genesisAlloc', 'minerRewards', 'uncleRewards'].indexOf(req.params.act) > -1) {
act = req.params.act;
if (act === 'total') {
act = 'totalSupply';
Expand Down Expand Up @@ -237,7 +237,9 @@ var getTotalSupply = function(req, res) {
}

var totalSupply = total.plus(genesisAlloc);
var ret = { "height": blockNumber, "totalSupply": totalSupply.div(1e+18), "genesisAlloc": genesisAlloc.div(1e+18), "minerRewards": total.div(1e+18) };
// circulationSupply = totalSupply - longterm reserve
var circulatingSupply = totalSupply.minus(rewards.longtermReserve || 0);
var ret = { "height": blockNumber, "circulatingSupply": circulatingSupply.div(1e+18), "totalSupply": totalSupply.div(1e+18), "genesisAlloc": genesisAlloc.div(1e+18), "minerRewards": total.div(1e+18) };
if (req.method === 'POST' && typeof rewards.genesisAlloc === 'object') {
ret.genesisAlloc = rewards.genesisAlloc;
}
Expand Down Expand Up @@ -266,6 +268,7 @@ var getTotalSupply = function(req, res) {
});
ret.uncleRewards = totalUncleRewards.div(1e+18);
ret.totalSupply = totalSupply.plus(totalUncleRewards).div(1e+18);
ret.circulatingSupply = circulatingSupply.plus(totalUncleRewards).div(1e+18);
if (req.method === 'GET' && act) {
res.write(ret[act].toString());
} else {
Expand All @@ -289,6 +292,7 @@ var getTotalSupply = function(req, res) {
});
ret.uncleRewards = totalUncleRewards.div(1e+18);
ret.totalSupply = totalSupply.plus(totalUncleRewards).div(1e+18);
ret.circulatingSupply = circulatingSupply.plus(totalUncleRewards).div(1e+18);
}
if (req.method === 'GET' && act) {
res.write(ret[act].toString());
Expand Down

0 comments on commit 92357b7

Please sign in to comment.