Motivation
This PR refactors ProcessNewBlock() and ProcessNewBlockHeaders() to return BlockValidationState by value instead of using out-parameters or boolean returns. This follows the pattern established in #31981 (commit 74690f4) which refactored TestBlockValidity() in a similar manner.
Current Issues
- ProcessNewBlockHeaders(): Uses an out-parameter
BlockValidationState& state, making the API less intuitive. - ProcessNewBlock(): Returns a simple boolean with no information about why validation failed.
- bitcoinkernel API:
btck_chainstate_manager_process_block()returns int (0/-1) with no way for library users to determine validation failure reasons without registering callbacks.
As noted by @theCharlatan in #33822 comment and can be a fix for that too:
One thing that could be considered here is returning the BlockValidationState directly instead of having an in/out param. To safely do that I think we’d need to refactor ProcessNewBlockHeaders though, similarly to what was done in 74690f4.
The changes are split into 3 commits, see individual commit message for more info.