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

[Consensus] Protect mapBlockIndex with its own mutex #951

Merged
merged 2 commits into from
Jun 15, 2021

Commits on May 31, 2021

  1. Give mapBlockIndex its own lock.

    Declare mapBlockIndex to be protected by cs_mapblockindex.
    
    Move a lot of generic lookups to LookupBlockIndex, while
    other more complex uses (e.g. atomic lookup+insert) are left alone.
    
    Make sure the lock is taken everywhere necessary (places found with clang
    thread-safety warnings) and only as tightly as possible to avoid
    potential lock cycles (detectable by tsan).
    
    Many uses of cs_main are replaced by cs_mapblockindex if they were only
    protecting mapBlockIndex, or removed (LookupBlockIndex taking the lock
    itself), or moved to after LookupBlockIndex calls.
    
    Rework PruneStaleBlockIndexes to do most work without the lock.
    Zannick committed May 31, 2021
    Configuration menu
    Copy the full SHA
    ad442a4 View commit details
    Browse the repository at this point in the history
  2. chain: Set all CBlockIndex members to null, remove SetNull helper

    ===
    Veil: cannot presently remove SetNull helper due to other use,
    however, this is still worthwhile due to the initialization changes.
    MarcoFalke authored and Zannick committed May 31, 2021
    Configuration menu
    Copy the full SHA
    13dd025 View commit details
    Browse the repository at this point in the history