Optimizations & simplifications following #25717
This contains a list of most-unrelated simplifications and optimizations to the code merged in #25717:
-
Make
ProcessNextHeadersreplace the headers argument: this allows reusing the same vector storage for input and output headers toHeadersSync::ProcessNextHeaders. I find it also natural in the sense that this argument just represents the headers-to-be-processed, both in the caller and the callee, and both before and after the calls. -
Make
ProcessNextHeaderssupport empty headers message: remove the special case inProcessHeadersMessagedealing with empty headers messages, and instead letHeadersSyncdeal with it correctly. -
Simplify
TryLowWorkHeadersSyncinvocation: make use of the fact that nowTryLowWorkHeadersSyncis (likeIsContinuationOfLowWorkHeadersSync) an operation that partially processes headers, it can be invoked in a similar way, bailing out when there is nothing left to do. -
Avoid an
IsAncestorOfBestHeaderOrTipcall: just don't call this function when it won't have any effect -
Compute work from headers without
CBlockIndex: avoid the need to construct aCBlockIndexobject just to compute work for a header, when itsnBitsvalue suffices for that. Also use someSpans where possible. -
Remove useless
CBlock::GetBlockHeader(it inherits from it): There is no need for a function to convert aCBlockto aCBlockHeader, as it's a child class of it.
These are not reactions to review feedback, and isn't intended for 24.0.