This adds an RPC method to fetch a block directly from a peer. This can used to fetch stale blocks with lower proof of work that are normally ignored by the node (headers-only in getchaintips).
Limitations:
- you have to specify which peer to fetch the block from
- the node must already have the header
Co-authored-by: John Newbery <john@johnnewbery.com>
This is a backport of core#20295, core#23702 and core#23706 (partial)
https://github.com/bitcoin/bitcoin/pull/20295/commits/dce8c4c38111556ca480aa0e63c46b71f66b508f
https://github.com/bitcoin/bitcoin/pull/23702/commits/aaaa34e34db6ff0f9ca3407bda42e7f0db887737
https://github.com/bitcoin/bitcoin/pull/23706/commits/bfbf91d0b2004dde358253ac174982f784b43b59
https://github.com/bitcoin/bitcoin/pull/23706/commits/809d66bb65aa78048e27c2a878d6f7becaecfe11
https://github.com/bitcoin/bitcoin/pull/23706/commits/0e3d7c5ee16d5a4c061ab9a57285bceb7899b512
The main commit is the first one. The other commits are minor style & comments improvements, and one commit removing an unnecessary argument in the newly added FetchBlock function.