Extract code that erases orphans when a new block is found into
EraseOrphansForBlock.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/21148 | core#21148]] [10/14]
https://github.com/bitcoin/bitcoin/pull/21148/commits/03257b832debcb1470420d8657d30ba30f4be770
Depends on D11487