net: Serve blocks directly from disk when possible
Summary:
In ProcessGetBlockData, send the block data directly from disk if
a non-compact block is requested. This is a valid shortcut as the
on-disk format matches the network format.
This is expected to increase performance because a deserialization and
subsequent serialization roundtrip is avoided.
This is a backport of core#13151
Note that this is a very old PR (2018) so we need to include a number of other changes that were ignored in previous backports (or not yet fully backported). Some notable ones are:
- https://github.com/bitcoin/bitcoin/pull/22932/commits/5d59ae0ba88849b1eb0d7350871bc19fcd5ef601
- https://github.com/bitcoin/bitcoin/pull/26415/commits/da338aada7943c392013c36c542af621fbc6edd1
- https://github.com/bitcoin/bitcoin/pull/27125/commits/f0bb1021f0d60f5f19176e67a66fcf7c325f88d1
Test Plan:
ninja all check-all
run on mainnet for a while, check the logs to make sure we are not unexpectedly disconneted by peers receiving our blocks
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18952