Skip to content

Optimizations & simplifications following #25717

This contains a list of most-unrelated simplifications and optimizations to the code merged in #25717:

  • Make ProcessNextHeaders replace the headers argument: this allows reusing the same vector storage for input and output headers to HeadersSync::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 ProcessNextHeaders support empty headers message: remove the special case in ProcessHeadersMessage dealing with empty headers messages, and instead let HeadersSync deal with it correctly.
  • Simplify TryLowWorkHeadersSync invocation: make use of the fact that now TryLowWorkHeadersSync is (like IsContinuationOfLowWorkHeadersSync) 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 IsAncestorOfBestHeaderOrTip call: just don't call this function when it won't have any effect
  • Compute work from headers without CBlockIndex: avoid the need to construct a CBlockIndex object just to compute work for a header, when its nBits value suffices for that. Also use some Spans where possible.
  • Remove useless CBlock::GetBlockHeader (it inherits from it): There is no need for a function to convert a CBlock to a CBlockHeader, as it's a child class of it.

These are not reactions to review feedback, and isn't intended for 24.0.

Merge request reports

Loading