Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate new round active delegate list from memory and not from database #850

Closed
fix opened this issue Aug 12, 2018 · 1 comment
Closed
Assignees

Comments

@fix
Copy link
Contributor

fix commented Aug 12, 2018

Is your feature request related to a problem? Please describe.
Right now the calculation of the delegate list is made from database. This degrades performance because the wallets that have changed during last round should be synced with database before the calculation occurs. Using very costly upsert.

see the note https://github.com/ArkEcosystem/core/blob/blockchain_fix/packages/core-database-sequelize/lib/connection.js#L323

Describe the solution you'd like
The best way would be to to the calculation in wallet manager with a function calculateDelegateList(delegateMax = 51) inside https://github.com/ArkEcosystem/core/blob/blockchain_fix/packages/core-database/lib/wallet-manager.js#L16
consisting on 2 separate actions:

  • updating each delegate wallets with balance of voters
  • sorting top most voted delegate wallets.

and use it instead of the database calculation here https://github.com/ArkEcosystem/core/blob/blockchain_fix/packages/core-database/lib/interface.js#L71 instead of a database implementation

Describe alternatives you've considered
Even better would be to update the votes here https://github.com/ArkEcosystem/core/blob/blockchain_fix/packages/core-database/lib/wallet-manager.js inside the 4 functions:

  • applyTransaction
  • revertTransaction
  • applyBlock
  • revertBlock

in the end getting the delegate list would be as simple as sorting the most voted wallets

@faustbrian
Copy link
Contributor

Can now be resolved by making use of https://github.com/ArkEcosystem/core/tree/develop/packages/core-storage

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

No branches or pull requests

4 participants