The lambda captures a reference to the chainman unique_ptr to retrieve
block data. An assert is added on the chainman to ensure that the lambda
is not used while the chainman is uninitialized.
This is done in preparation for the following commits where blockstorage
functions are made BlockManager methods.
This is a partial backport of core#27125
https://github.com/bitcoin/bitcoin/pull/27125/commits/cfbb2124939822e95265a39242ffca3d86bac6e8
Depends on D16182