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

Redundant logic in getBlockSlotData #2422

Closed
4miners opened this issue Sep 26, 2018 · 0 comments · Fixed by #2488
Closed

Redundant logic in getBlockSlotData #2422

4miners opened this issue Sep 26, 2018 · 0 comments · Fixed by #2488
Assignees
Milestone

Comments

@4miners
Copy link
Contributor

4miners commented Sep 26, 2018

Expected behavior

Logic in modules.delegates->__private.getBlockSlotData should be something like following:

  • Call generateDelegatesList.
  • Return keypair when delegate for current slot exists in __private.keypairs (forging enabled) or null if not.

Then in __private.forge:

Actual behavior

Function modules.delegates->__private.getBlockSlotData is using following logic:

  • Call generateDelegatesList.
  • Iterate 101 times (through slots) until it finds delegate public key in __private.keypairs.
  • Returns slot time together with corresponding keypair or null if it cannot found delegate on the list (forging enabled, but delegate is not the active one).

This function is called form __private.forge in the same module, but later we have a check here:
https://github.com/LiskHQ/lisk/blob/7922d346e115406a0004aa729e2ecfd18c5d43e4/modules/delegates.js#L263-L265 This check is true most of the times because delegate can forge only once during the round (in perfect conditions).

This logic is redundant and unnecessary complex.

Steps to reproduce

N/A

Which version(s) does this affect? (Environment, OS, etc...)

>= 1.0.0

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

Successfully merging a pull request may close this issue.

3 participants