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?
- 1Bitcoin 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– Pieter Wuille2021-12-10 19:54:10 +00:00Commented Dec 10, 2021 at 19:54
Add a comment |
1 Answer
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.
- 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– MHT2021-12-19 12:21:08 +00:00Commented Dec 19, 2021 at 12:21