Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Sort validators by stake desc
Browse files Browse the repository at this point in the history
  • Loading branch information
ilblackdragon committed Apr 27, 2020
1 parent f228580 commit 414a597
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commands/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ module.exports = {
const seatPrice = findSeatPrice(validators.current_validators, numSeats);
const nextSeatPrice = findSeatPrice(validators.next_validators, numSeats);

// Sort validators by their stake.
validators.current_validators = validators.current_validators.sort((a, b) => -new BN(a.stake).cmp(new BN(b.stake)));
validators.next_validators = validators.next_validators.sort((a, b) => -new BN(a.stake).cmp(new BN(b.stake)));

var validatorsTable = new AsciiTable();
validatorsTable.setHeading('Validator Id', 'Stake', '# seats', '% online', 'bls produced', 'bls expected');
console.log(`Validators (total: ${validators.current_validators.length}, seat price: ${utils.format.formatNearAmount(seatPrice, 0)}):`);
Expand Down

0 comments on commit 414a597

Please sign in to comment.