Files
bitcoin/src
merge-script 81e67d9aa1 Merge bitcoin/bitcoin#34179: refactor: Enable transparent lookup for setBlockIndexCandidates to remove const_cast
3bd98b4508 refactor: use transparent comparator for setBlockIndexCandidates lookups (joaonevess)

Pull request description:

  ### Rationale

  This PR improves code safety by removing a `const_cast` in `src/validation.cpp`.

  Currently, `setBlockIndexCandidates` stores mutable `CBlockIndex*`. However, validation logic (like `CVerifyDB`) often holds `const CBlockIndex*`. Previously, checking for existence in the set required casting away constness. While currently benign, this bypasses compiler safety checks and could mask accidental modifications in future refactors.

  ### Description

  1.  **Enable Heterogeneous Lookup:** Added `using is_transparent = void;` to `CBlockIndexWorkComparator` in `src/node/blockstorage.h`. This allows the `std::set` to natively accept `const CBlockIndex*` for lookup (utilizing C++14 heterogeneous lookup).
  2.  **Remove Cast:** Removed the now unnecessary `const_cast<CBlockIndex*>` in `src/validation.cpp`, allowing the compiler to strictly enforce const-correctness.

  ### Notes

  - **Refactoring only:** No behavioral change.
  - **Verification:** `validation_tests` and `blockmanager_tests` pass.

ACKs for top commit:
  maflcko:
    review ACK 3bd98b4508 🚪
  frankomosh:
    ACK 3bd98b4508. Good use of transparent comparator to eliminate `const_cast` in this specific code path.
  sedited:
    ACK 3bd98b4508

Tree-SHA512: 0f76bdce2a54b759dfec99633afce1e95586e62f4057ecf1e82eed1a073eb8ecb2d659ccbf28a7a139f0aa09a30f058ac6966cafdfbf1f2ee878fa2d86b2c487
2026-02-02 08:49:02 +01:00
..
2025-09-03 11:23:30 +01:00
2025-09-30 11:06:43 -07:00
2026-01-22 10:35:14 -05:00
2025-11-14 01:17:38 +02:00
2025-11-14 01:17:38 +02:00