Remove unused SetTip(nullptr) code #25023

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2204-rem-nullptr-👯 changing 5 files +15 −16
  1. MarcoFalke commented at 7:24 AM on April 29, 2022: member

    Now that this path is no longer used after commit b51e60f91472da5216116626afc032acd5616e85, we can remove it.

    Future code should reset CChain by simply discarding it and constructing a fresh one.

  2. MarcoFalke added the label Refactoring on Apr 29, 2022
  3. pk-b2 commented at 4:47 AM on May 2, 2022: none
  4. DrahtBot cross-referenced this on May 6, 2022 from issue test: Cleanup miner_tests by MarcoFalke
  5. DrahtBot commented at 10:19 PM on May 6, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #25073 (test: Cleanup miner_tests by MarcoFalke)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  6. fanquake requested review from ajtowns on May 9, 2022
  7. fanquake requested review from jamesob on May 9, 2022
  8. DrahtBot cross-referenced this on Jul 16, 2022 from issue CBlockIndex/CDiskBlockIndex improvements for safety, consistent behavior by jonatack
  9. DrahtBot added the label Needs rebase on Jul 25, 2022
  10. MarcoFalke force-pushed on Jul 25, 2022
  11. DrahtBot removed the label Needs rebase on Jul 25, 2022
  12. in src/validation.cpp:2627 in faf57a6898 outdated
    2623 | @@ -2624,7 +2624,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr
    2624 |          }
    2625 |      }
    2626 |  
    2627 | -    m_chain.SetTip(pindexDelete->pprev);
    2628 | +    m_chain.SetTip(*Assert(pindexDelete->pprev));
    


    ryanofsky commented at 7:40 PM on August 2, 2022:

    In commit "Remove unused SetTip(nullptr) code" (faf57a6898590cecfbb918d73abbf2c100206b8e)

    I think it would be good to add an assert to the top of the function to make it more obvious it will crash if called on the genesis block:

    diff --git a/src/validation.cpp b/src/validation.cpp
    index da18fec1d85..75d06841e3f 100644
    --- a/src/validation.cpp
    +++ b/src/validation.cpp
    @@ -2577,6 +2577,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr
     
         CBlockIndex *pindexDelete = m_chain.Tip();
         assert(pindexDelete);
    +    assert(pindexDelete->pprev);
         // Read block from disk.
         std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
         CBlock& block = *pblock;
    
    

    MarcoFalke commented at 8:28 AM on August 3, 2022:

    Nice, done.

  13. ryanofsky approved
  14. ryanofsky commented at 7:47 PM on August 2, 2022: contributor

    Code review ACK faf57a6898590cecfbb918d73abbf2c100206b8e

  15. Remove unused SetTip(nullptr) code faab8dceb3
  16. MarcoFalke force-pushed on Aug 3, 2022
  17. ryanofsky approved
  18. ryanofsky commented at 3:12 PM on August 4, 2022: contributor

    Code review ACK faab8dceb37a944d0763fcca390342111e6a9fcc. Just moved an assert statement since last review

  19. fanquake merged this on Aug 4, 2022
  20. fanquake closed this on Aug 4, 2022

  21. MarcoFalke deleted the branch on Aug 4, 2022
  22. sidhujag referenced this in commit ffc29c5ccd on Aug 4, 2022
  23. bitcoin locked this on Aug 4, 2023


jamesobajtowns


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:53 UTC