As summarized in this TODO, we should batch request checkpoint blocks.
The comment's text is somewhat outdated (its specific suggestion about unnecessary blocks in particular refers to a previous version of the code, before this commit changed from using GetBlocks to GetTopologyAtHeight).
Although some of the details in the comment are obsolete, it's broadly correct in that the API isn't quite right:
We want to batch request every checkpoint height to avoid O(n) round-trips
We want to only ask about blocks on the main fork [1]
[1] The current code requests blocks on all forks. It only rejects the peer if the peer has at least one block at the checkpoint height, and none of the blocks it has match the checkpoint ID. (This check is repeated for each checkpoint.)
As summarized in this TODO, we should batch request checkpoint blocks.
The comment's text is somewhat outdated (its specific suggestion about unnecessary blocks in particular refers to a previous version of the code, before this commit changed from using
GetBlocks
toGetTopologyAtHeight
).Although some of the details in the comment are obsolete, it's broadly correct in that the API isn't quite right:
[1] The current code requests blocks on all forks. It only rejects the peer if the peer has at least one block at the checkpoint height, and none of the blocks it has match the checkpoint ID. (This check is repeated for each checkpoint.)