validation: reduce block index comparison overhead

bitcoin/bitcoin: PR #33637

1 suggestion

Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · Comparator test does not isolate sequence-ID precedence

The new comparator test would still pass all 49 assertions if nSequenceId were omitted or compared after the pointer.

Location: src/test/blockchain_tests.cpp:149 (head).

Details and suggested fix

The equal-work entries sit in expected best-to-worst order in one std::array, so descending address order alone satisfies i > j. Comparing work and then address therefore produces every expected result. Putting the pointer before nSequenceId also hides that key because distinct element pointers never tie. Store {2, 20} before {2, 10} and check against an explicitly specified best-to-worst pointer ranking. Keep the duplicate-key pair so the pointer tie-break remains covered.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.