Part of #36833.
Based on #36920; review from refactor: extract block serving limit checks.
This PR lets peers fetch the blocks behind the stale tips announced in #36920. We now serve blocks on the stale branches we track, and the new -staletips=blocks mode downloads the branches peers offer.
Key changes
-staletips=blocksadvertisesprefers_blocks=trueand fetches offered branches. For peers that prefer blocks, we wait to announce a tip until we've fetched it, unless the fetch stalls.- Fetches are best-effort and separate from normal block download:
- They start at the tip, since that's all
have_blockpromises. - Each block is requested from one peer at a time, and only while that peer has fewer than 8 blocks in flight.
- They start at the tip, since that's all
- This also fixes how #36920 handles a higher-work
staletip. It used to go through normal block download, which expected every ancestor from that peer and could disconnect it. Now it's fetched best-effort, in both modes.