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

multi: Decouple orphan handling from blockchain. #2008

Merged
merged 1 commit into from
Dec 6, 2019

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Nov 20, 2019

This decouples and removes the orphan handling from blockchain in favor of implementing it in the block manager as part of the overall effort to decouple the connection code from the download logic.

The change might not make a ton of sense in isolation, since there is no major functional change, however, decoupling the orphan handling independently helps make the review process easier and alleviates what would otherwise result in additional intermediate code to handle cases that ultimately will no longer exist.

The following is a high level overview of the changes:

  • Introduce blockchain function to more easily determine if an error is a rule error with a given error code
  • Move core orphan handling code from blockchain to block manager
    • Move data structures used to cache and track orphan blocks
    • Move all functions releated to orphans
      • BlockChain.IsKnownOrphan -> blockManager.isKnownOrphan
      • BlockChain.GetOrphanRoot -> blockManager.orphanRoot
      • BlockChain.removeOrphanBlock -> blockManager.removeOrphanBlock
      • BlockChain.addOrphanBlock -> blockManager.addOrphanBlock
  • Implement orphan handling in block manager
    • Rework to use the moved functions and data structs
    • Add check for known orphans in addition HaveBlock calls to retain the same behavior
  • Remove remaining orphan related code from blockchain
    • Update ProcessBlock to return an error when called with an orphan
    • Remove additional orphan processing from ProcessBlock
    • Remove orphan cache check from HaveBlock
    • Adjust example to account for the removed parameter
    • Change chaingen harness tests to detect orphans via returned error
    • Modify fullblock tests to detect orphans via returned error
    • Adapt process order logic tests to cope with lack of orphan processing
    • Update all other tests accordingly
    • Update various comments and the README.md and doc.go to properly reflect the removal of orphan handling

This is work towards #1145.

@davecgh davecgh added this to the 1.6.0 milestone Nov 20, 2019
blockmanager.go Outdated Show resolved Hide resolved
Copy link
Member

@matheusd matheusd left a comment

Choose a reason for hiding this comment

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

Working fine now, thanks!

blockmanager.go Outdated Show resolved Hide resolved
@davecgh davecgh force-pushed the blockchain_decouple_orphan_handling branch from 0e25aa9 to 5db810a Compare December 3, 2019 06:41
This decouples and removes the orphan handling from blockchain in favor
of implementing it in the block manager as part of the overall effort to
decouple the connection code from the download logic.

The change might not make a ton of sense in isolation, since there is no
major functional change, however, decoupling the orphan handling
independently helps make the review process easier and alleviates what
would otherwise result in additional intermediate code to handle cases
that ultimately will no longer exist.

The following is a high level overview of the changes:

- Introduce blockchain function to more easily determine if an error is
  a rule error with a given error code
- Move core orphan handling code from blockchain to block manager
  - Move data structures used to cache and track orphan blocks
  - Move all functions releated to orphans
    - BlockChain.IsKnownOrphan -> blockManager.isKnownOrphan
    - BlockChain.GetOrphanRoot -> blockManager.orphanRoot
    - BlockChain.removeOrphanBlock -> blockManager.removeOrphanBlock
    - BlockChain.addOrphanBlock -> blockManager.addOrphanBlock
- Implement orphan handling in block manager
  - Rework to use the moved functions and data structs
  - Add check for known orphans in addition HaveBlock calls to retain
    the same behavior
  - Modify the semantics of the process block func exposed by the block
    manager so that it no longer stores orphans since all consumers of
    it ultimately reject orphans anyway
- Remove remaining orphan related code from blockchain
  - Update ProcessBlock to return an error when called with an orphan
  - Remove additional orphan processing from ProcessBlock
  - Remove orphan cache check from HaveBlock
  - Adjust example to account for the removed parameter
  - Change chaingen harness tests to detect orphans via returned error
  - Modify fullblock tests to detect orphans via returned error
  - Adapt process order logic tests to cope with lack of orphan
    processing
  - Update all other tests accordingly
  - Update various comments and the README.md and doc.go to properly
    reflect the removal of orphan handling
@davecgh davecgh force-pushed the blockchain_decouple_orphan_handling branch from 5db810a to f140d33 Compare December 6, 2019 03:39
@davecgh davecgh merged commit f140d33 into decred:master Dec 6, 2019
@davecgh davecgh deleted the blockchain_decouple_orphan_handling branch December 6, 2019 03:43
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.

None yet

4 participants