UndoWriteToDisk
and WriteBlockToDisk
were delegating a subset of their functionality to single-use methods that didn’t optimally capture a meaningful chunk of the algorithm, resulting in calculating things twice (serialized size, header size).
This change inlines the awkward methods (asserting that all previous behavior was retained), and in separate commits makes the usages less confusing.
Besides making the methods slightly more intuitive, the refactorings reduce duplicate calculations as well.
The speed difference is insignificant for now (~0.5% for the new SaveBlockToDiskBench
), but are a cleanup for follow-ups such as #31539
This change is a precursor to https://github.com/bitcoin/bitcoin/pull/31539