<p>The raw block data is downloaded, and nothing else.  All block and transaction indexes are created locally.  In the process, block hashes are checked and transactions are verified (to various degrees) as to whether they spend valid inputs, are properly signed, and so on.</p>

<p>Each block is checked and added to the index immediately after being downloaded.    The software doesn't wait to download all the blocks before starting to index them.</p>

<p>The files in <code>blocks/index</code> contain information to help locate blocks.  For instance, it would contain an entry for each block with its hash, other relevant header data, the number of the <code>blk*.dat</code> file where it is stored, and the position within that file.  If <code>txindex</code> is enabled, these files also contain one entry per transaction, pointing to the location of the block which contains the transaction, and the position of the transaction within that block.</p>

<p>The index of unspent transaction outputs is found in the <code>chainstate</code> directory.</p>

<p>The best resource to learn about these indexes is to read the Bitcoin Core source code.  There is an older writeup at <a href="https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage</a>, but as of 0.15.0 at least the chainstate index has changed significantly (thanks  Pieter Wuille).  It is also explained at <a href="https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair">What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?</a>.</p>

CC BY-SA 3.0
2017-09-24T02:08:37.073Z
Do you mean that all blocks are downloaded from a peer or some peers first, and then the local process produces indexes based on the heads of the downloaded blocks? In addition, I want to know  whether those .ldb files cached in the directory "/block/index"  are transaction indexes or the index information about the location to download the blocks. Which one is the right answer?
Trl
CC BY-SA 3.0
2017-09-24T02:18:03.640Z
@Trl: See edit.
Nate Eldredge
CC BY-SA 3.0
2017-09-24T02:43:23.970Z
Thank you for recommending this information. Thank you very much！
Trl
CC BY-SA 3.0
2017-09-25T08:53:26.153Z
The format of the chainstate database was overhauled in Bitcoin Core 0.15.
Pieter Wuille
CC BY-SA 3.0
2017-09-23T15:11:44.347Z
2017-09-25T13:30:23.643Z
2017-09-25T13:30:23.643Z
Nate Eldredge
<p>What is the work done by the bitcoin core client during the initialization process? Is the block index created locally or downloaded at other partner nodes?</p>

<blockchain><synchronization>
Bitcoin block index synchronization
Trl
# Bitcoin block index synchronization

(Asked by: username_0 on 2017-09-23)

What is the work done by the bitcoin core client during the initialization process? Is the block index created locally or downloaded at other partner nodes?

**Tags:** blockchain, synchronization


---

## 1 answers

### Answer by username_1 on 2017-09-23. Score: 1

The raw block data is downloaded, and nothing else. All block and transaction indexes are created locally. In the process, block hashes are checked and transactions are verified (to various degrees) as to whether they spend valid inputs, are properly signed, and so on.

Each block is checked and added to the index immediately after being downloaded. The software doesn't wait to download all the blocks before starting to index them.

The files in `blocks/index` contain information to help locate blocks. For instance, it would contain an entry for each block with its hash, other relevant header data, the number of the `blk*.dat` file where it is stored, and the position within that file. If `txindex` is enabled, these files also contain one entry per transaction, pointing to the location of the block which contains the transaction, and the position of the transaction within that block.

The index of unspent transaction outputs is found in the `chainstate` directory.

The best resource to learn about these indexes is to read the Bitcoin Core source code. There is an older writeup at <https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage>, but as of 0.15.0 at least the chainstate index has changed significantly (thanks username_2). It is also explained at [What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?](https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair).

> **Comments:**
> **username_0**: Do you mean that all blocks are downloaded from a peer or some peers first, and then the local process produces indexes based on the heads of the downloaded blocks? In addition, I want to know  whether those .ldb files cached in the directory "/block/index"  are transaction indexes or the index information about the location to download the blocks. Which one is the right answer?  
> **username_1**: @username_0: See edit.  
> **username_0**: Thank you for recommending this information. Thank you very much！  
> **username_2**: The format of the chainstate database was overhauled in Bitcoin Core 0.15.  

---

