Add helper function for checking header continuity
Summary:
This is a partial backport of core#25454
https://github.com/bitcoin/bitcoin/pull/25454/commits/9492e93bf9f4a841bf43ca4b593871c0863d5b63
Depends on D14906
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14907