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

Sort delegates for nextForgers endpoint - Closes #1811 #1812

Merged
merged 2 commits into from
Apr 3, 2018

Conversation

SargeKhan
Copy link
Contributor

What was the problem?

Next forgers were not sorted by their slot number.

How did I fix it?

Sorted the delegates before sending the response.

How to test it?

Call /api/delegates/forgers endpoint

Review checklist

@SargeKhan SargeKhan self-assigned this Apr 3, 2018
@SargeKhan SargeKhan added the *easy label Apr 3, 2018
@SargeKhan SargeKhan added this to the Version 1.0.0-alpha.4 milestone Apr 3, 2018
@MaciejBaj MaciejBaj removed this from the Version 1.0.0-alpha.4 milestone Apr 3, 2018
@MaciejBaj MaciejBaj merged commit 824b37e into 1.0.0 Apr 3, 2018
@MaciejBaj MaciejBaj deleted the 1811-sort_order_for_forger branch April 3, 2018 17:18
@@ -799,12 +799,13 @@ Delegates.prototype.getForgers = function(query, cb) {
library.db.delegates
.getDelegatesByPublicKeys(forgerKeys)
.then(rows => {
rows.map(forger => {
rows.forEach(forger => {
forger.nextSlot =
activeDelegates.indexOf(forger.publicKey) + currentSlot + 1;

return forger;
Copy link

@fmal fmal Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to return here, forEach is meant for side effect

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants