Skip to content

Instantly share code, notes, and snippets.

@lsilvs
Created November 6, 2018 14:23
Show Gist options
  • Save lsilvs/5202bde7596b9c514c98927428b1a7c6 to your computer and use it in GitHub Desktop.
Save lsilvs/5202bde7596b9c514c98927428b1a7c6 to your computer and use it in GitHub Desktop.
Get the list of all registered Lisk Delegates
const async = require('async');
const _ = require('lodash');
const client = require('lisk-elements');
const limit = 100;
let offset = 0;
let delegatesList = [];
async.doUntil(
(next) => {
client.delegates
.get({ limit, offset })
.then(res => {
next(null, res);
});
},
(data) => {
delegatesList = _.union(delegatesList, data);
offset += limit;
return data.length < limit;
},
(err) => {
// list of all delegates
return delegatesList;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment