Where does Bitcoin Core store DB_LAST_BLOCK?

0

My understanding is that Bitcoin Core stores where it left off(DB_LAST_BLOCK) in $DATADIR/blocks/index.

But which is the actual file bitcoin core stores it at?

kcalvinalvin

Posted 2019-10-31T17:07:05.540

Reputation: 111

DB_LAST_BLOCK is just the highest index blk*.dat file number that's in use. To know what the tip of the currently validated chain is, look for DB_BEST_BLOCK.Pieter Wuille 2019-10-31T22:05:28.443

And both of them are handled by leveldb so we don’t know exactly where they are stored?kcalvinalvin 2019-11-01T03:00:17.197

They're stored in LevelDB. How LevelDB chooses to format that in files is not something we care about. You need a LevelDB library to read it, but generally you really shouldn't (it's also impossible while Bitcoin Core is running, as LevelDB is only designed for single-process access). If you need to know up to where Bitcoin Core is synchronized, use the getblockchaininfo RPC call.Pieter Wuille 2019-11-01T03:06:54.580

Answers

2

It depends on your specific data directory. Bitcoin Core uses a LevelDB database for the index and LevelDB handles the exact storage format and files of the database. This can be different for every data directory. There is no particular file that that record is stored in that Bitcoin Core knows.

Andrew Chow

Posted 2019-10-31T17:07:05.540

Reputation: 40 910