
When one peer stalls the movement of the window, it is disconnected. Blocks are fetched in parallel from all available outbound peers, using a limited moving window.Do not use 'getblocks', but 'getheaders', and use it to build a headers tree.Headers-first IBD was merged in 2014 in: Pull Request 4468.Īs summarized in the PR comment, some of its main features are : (It downloads headers from only one peer, but that's no big deal since headers are small.) The node will download from up to 8 peers at once and will disconnect any peer that stalls for more 2 seconds, attempting to connect to a faster peer.

Now that it has the headers, the node downloads blocks in parallel from multiple peers.
#Bitcoin core code full
Once the node has all of the headers, from the genesis block up to the current tip of the blockchain (380,000 as of October 2015), only then does it begins downloading the full blocks. With "headers-first" mode, a new node downloads all of the block headers first, which are very small (about 80 bytes, whereas a block can be up to 1MB). This approach resulted in a substantial speedup. Developers agreed that this was unacceptable and a new approach was developed called "headers first" mode. Various optimizations have been made since Satoshi's original client was released, but as of 2014, with increasing transaction volume, initial download on laptop hardware with an average connection could still take up to 24 hours.

This is an integral step to the distributed nature of bitcoin because only by doing this can a node claim that it has independently validated all transactions.Īs the blockchain grows in size, the time required for IBD increases unless optimizations are made to the code. Once a new node joins the network, its first order of business is to download and validate the entire blockchain.
