Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #31 from ztsai/totalValidators
Browse files Browse the repository at this point in the history
fixes #29 Wrong number of total validators and delegated tokens
  • Loading branch information
kwunyeung authored Apr 23, 2019
2 parents 184e5e8 + 8edd7c8 commit 44aff89
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions imports/api/chain/server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,15 @@ Meteor.methods({
chain.activeVotingPower = activeVP;

let totalVP = 0;

if (parseInt(chain.latestBlockHeight) > 0){
url = LCD+'/staking/validators';
response = HTTP.get(url);
let validatorSet = JSON.parse(response.content);
chain.totalValidators = validatorSet.length;

for (v in validatorSet){
let vp = Math.round(parseFloat(eval(validatorSet[v].tokens)));
chain.totalValidators = Validators.find({}).count();
Validators.find({}).forEach((v) => {
url = `${LCD}/staking/validators/${v.operator_address}`;
response = HTTP.get(url);
validator = JSON.parse(response.content)
let vp = Math.round(parseFloat(eval(validator.tokens)));
totalVP += parseInt(vp);
}
});
}

chain.totalVotingPower = totalVP;
Expand Down

0 comments on commit 44aff89

Please sign in to comment.