Created
November 6, 2018 14:23
-
-
Save lsilvs/5202bde7596b9c514c98927428b1a7c6 to your computer and use it in GitHub Desktop.
Get the list of all registered Lisk Delegates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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