> Replace overriden index Init() methods that use the best block
> CBlockIndex* pointer with pure CustomInit() callbacks that are passed
> the block hash and height.
>
> This gets rid of more CBlockIndex* pointer uses so indexes can work
> outside the bitcoin-node process. It also simplifies the initialization
> call sequence so index implementations are not responsible for
> initializing the base class.
>
> There is a slight change in behavior here since now the best block
> pointer is loaded and checked before the custom index init functions are
> called instead of while they are called.
https://github.com/bitcoin/bitcoin/pull/25494/commits/bef4e405f3de2718dfee279a9abff4daf016da26
> index: prevent race by calling 'CustomInit' prior setting 'synced' flag
>
> The 'm_synced' flag enables 'BlockConnected' events to be processed by
> the index. If we set the flag before calling 'CustomInit', we could be
> dispatching a block connected event to an uninitialized index child
> class.
>
> e.g. BlockFilterIndex, initializes the next filter position
> inside 'CustomInit'. So, if `CustomInit` is not called prior receiving
> the block event, the index will use 'next_filter_position=0' which
> overwrites the first filter in disk.
https://github.com/bitcoin/bitcoin/pull/27720/commits/3126454dcfa1dd29bb66500d5f2b5261684d6c58
This is a backport of core#27720
Depends on D17721