<p>I think you are confusing what it means to store things &quot;in memory&quot;. As you say, indeed, the block index DB and the chainstate DB are both levelDB databases stored on disk. However, while Bitcoin Core is running, parts (or all) of these databases are loaded into memory to speed things up. The &quot;in memory&quot; part isn't a separate database. So there is no redundancy/duplication.</p>

CC BY-SA 4.0
2021-12-19T12:21:08.057Z
Then, both index DB and chainstate DB (the UTXO set) are loaded into memory to speed things up. But, what about the block header? And, when these data are loaded into memory?
MHT
CC BY-SA 4.0
2021-12-12T09:04:20.093Z
2021-12-12T09:04:20.093Z
meshcollider
<p>Bitcoin Core keeps block data as files in the file system and blocks indexes in a LevelDB database to make the search process of transactions and blocks faster. But Bitcoin Core also stores block headers in memory as well, doesn't it? If yes, what is the purpose of having both storage mechanisms together?</p>

CC BY-SA 4.0
2021-12-10T19:54:10.433Z
Bitcoin is just a protocol, and how implementations of that protocol deal with storage is up to them. Your stated assumptions however are correct for versions of Bitcoin Core, and software based on its codebase.
Pieter Wuille
<transaction-verification><database><storage><leveldb><memory>
Are the block headers kept in memory?
MHT
# Are the block headers kept in memory?

(Asked by: username_0 on 2021-12-10)

Bitcoin Core keeps block data as files in the file system and blocks indexes in a LevelDB database to make the search process of transactions and blocks faster. But Bitcoin Core also stores block headers in memory as well, doesn't it? If yes, what is the purpose of having both storage mechanisms together?

**Tags:** transaction-verification, database, storage, leveldb, memory

> **Comments:**
> **username_1**: Bitcoin is just a protocol, and how implementations of that protocol deal with storage is up to them. Your stated assumptions however are correct for versions of Bitcoin Core, and software based on its codebase.  

---

## 1 answers

### Answer by username_2 on 2021-12-12. Score: 3

I think you are confusing what it means to store things "in memory". As you say, indeed, the block index DB and the chainstate DB are both levelDB databases stored on disk. However, while Bitcoin Core is running, parts (or all) of these databases are loaded into memory to speed things up. The "in memory" part isn't a separate database. So there is no redundancy/duplication.

> **Comments:**
> **username_0**: Then, both index DB and chainstate DB (the UTXO set) are loaded into memory to speed things up. But, what about the block header? And, when these data are loaded into memory?  

---

