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

blockchain: Refactor to use new chain view. #1344

Merged
merged 1 commit into from
Jul 20, 2018

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jul 9, 2018

This requires #1338.

This refactors and simplifies the code in blockchain to use the new more efficient chain views.

An overview of the logic changes are as follows:

  • Remove inMainChain from block nodes since that can now be efficiently determined by using the chain view
  • Track the best chain via a chain view instead of a single block node
    • Use the tip of the best chain view everywhere bestNode was used
    • Update chain view tip instead of updating best node
  • Remove height map and associated lock in favor of chain view
    • Use chain view NodeByHeight everywhere height map was used
  • Change reorg logic to use more efficient chain view fork finding logic
  • Change block locator code over to use more efficient chain view logic
    • Remove now unused block-index-based block locator code
    • Move BlockLocator definition to chain.go
    • Move BlockLocatorFromHash and LatestBlockLocator to chain.go
      • Update both to use more efficient chain view logic
  • Rework several functions to use chain view for main chain detection
    • fetchMainChainBlockByNode
    • BlockByHeight
    • MainChainHasBlock
    • findPreviousCheckpoint
    • IsCheckpointCandidate

This is work towards #1145.

@davecgh davecgh added this to the 1.3.0 milestone Jul 9, 2018
@davecgh davecgh mentioned this pull request Jul 9, 2018
33 tasks
@davecgh davecgh force-pushed the blockchain_use_chainview branch 2 times, most recently from c0b3429 to 60361d0 Compare July 9, 2018 22:41
@dnldd
Copy link
Member

dnldd commented Jul 10, 2018

No issues encountered running on testnet.

@alexlyp
Copy link
Member

alexlyp commented Jul 11, 2018

Been running smooth on testnet for a while now

@raedah
Copy link
Contributor

raedah commented Jul 14, 2018

Ran for 5 days with no problems on testnet and mainnet.

Copy link
Member

@dajohi dajohi left a comment

Choose a reason for hiding this comment

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

testnet2 miner ok

This refactors and simplifies the code in blockchain to use the new more
efficient chain views.

An overview of the logic changes are as follows:

- Remove inMainChain from block nodes since that can now be efficiently
  determined by using the chain view
- Track the best chain via a chain view instead of a single block node
  - Use the tip of the best chain view everywhere bestNode was used
  - Update chain view tip instead of updating best node
- Remove height map and associated lock in favor of chain view
  - Use chain view NodeByHeight everywhere height map was used
- Change reorg logic to use more efficient chain view fork finding logic
- Change block locator code over to use more efficient chain view logic
  - Remove now unused block-index-based block locator code
  - Move BlockLocator definition to chain.go
  - Move BlockLocatorFromHash and LatestBlockLocator to chain.go
    - Update both to use more efficient chain view logic
- Rework several functions to use chain view for main chain detection
  - fetchMainChainBlockByNode
  - BlockByHeight
  - MainChainHasBlock
  - findPreviousCheckpoint
  - IsCheckpointCandidate
@davecgh davecgh merged commit 9ef7db9 into decred:master Jul 20, 2018
@davecgh davecgh deleted the blockchain_use_chainview branch July 20, 2018 22:29
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.

6 participants