I read the bitcoin docs describing how btc syncs. During IBD it gets the inventories up to the tip with getblock. Why does it not skip this step and get the blocks, generating the inventories as it gets each block? Surely getting inventories is slow, unneeded and inefficient? I believe bitcoin daemon over version 0.10.0 now sync headers rather than inventories, i am talking about pre 0.10.0.
-
1Your question contains too many misconceptions for me to answer... what do you mean by "skipping this step"? Syncing inventories exactly how the nodes learns about and downloads the blocks. I don't know what is slow, unneeded, or inefficient about it.– Pieter WuilleCommented Mar 8, 2020 at 23:56
-
@Wuille why would I need to download inventory’s to learn about the blocks? What does a number and a hash tell me that I can’t get from syncing the block data it’s self. Perhaps I have misunderstood the docs?– Leah CorneliusCommented Mar 9, 2020 at 5:49
-
The inventory is how you learn the block exists at all. It's how you figure out "oh this peer knows a block I don't have yet, let me ask for it".– Pieter WuilleCommented Mar 9, 2020 at 5:59
-
@pieter wuille ah I see. I was under the perception your node already knew this. Thanks :) this has answered the question. Feel free to put it into a response and I will mark it as correct! – Leo Cornelius– Leah CorneliusCommented Mar 9, 2020 at 6:58
-
1@Claris Sure about that? github.com/bitcoin/bitcoin/blob/v0.1.5/main.cpp#L1800– Pieter WuilleCommented Sep 12, 2023 at 10:32
1 Answer
Pre 0.10 versions synced inventories as it was the way they composed a list of blocks that they then recursively request from the peer. It provides multiple benefits over just asking for all blocks since timestamp x (where is the timestamp of the last block we had).
The biggest one being that it allows you to check the peer is on the same chain as the checkpoint you are using, this means you can check the peer is on the correct chain (eg the one your checkpoints state is correct) before downloading blocks, which are considerably larger than just hashes.