Skip to content
  • Dave Collins's avatar
    blockchain: Refactor to use new chain view. · 20910511
    Dave Collins authored
    - 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
    - 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 IsCheckpointCandidate to use block index and chain view
    - Optimize MainChainHasBlock to use chain view instead of hitting db
      - Move to chain.go since it no longer involves database I/O
      - Removed error return since it can no longer fail
    - Optimize BlockHeightByHash to use chain view instead of hitting db
      - Move to chain.go since it no longer involves database I/O
      - Removed error return since it can no longer fail
    - Optimize BlockHashByHeight to use chain view instead of hitting db
      - Move to chain.go since it no longer involves database I/O
      - Removed error return since it can no longer fail
    - Optimize HeightRange to use chain view instead of hitting db
      - Move to chain.go since it no longer involves database I/O
    - Optimize BlockByHeight to use chain view for main chain check
    - Optimize BlockByHash to use chain view for main chain check
    20910511