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

fix(core-database): straight delete blocks during rollback #3773

Merged

Conversation

rainydio
Copy link
Contributor

@rainydio rainydio commented Jun 3, 2020

Summary

Blockchain.removeTopBlocks now calls BlockRepository.deleteTopBlocks instead of loading them first through DatabaseService.getTopBlocks and then deleting through BlockRepository.deleteBlocks.

Note that previously Blockchain.removeTopBlocks was eating error, only logging it instead of re-throwing.

There are two use-cases when blocks have to be deleted:

  1. During rollback top 1000 blocks (up to 10000) are removed.
    Improved by this PR.
  2. When reverting, reverted blocks are deleted at the end.
    I plan to refactor revertion to use new BlockRepository.delgetTopBlock that pops single block from database rendering BlockRepository.deleteBlocks obsolete.

Checklist

  • Tests
  • Ready to be merged

@faustbrian faustbrian merged commit b87a7a8 into develop Jun 4, 2020
@ghost ghost deleted the fix/core-database/block-repository/delete-top-blocks branch June 4, 2020 02:12
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

Successfully merging this pull request may close these issues.

2 participants