I am working on a parser for the blk.dat
files being returned by the Bitcoin Core node. It seems to slow down considerably after a point and I am pretty sure it's because the number of transactions is increasing in the files. My question is, how many transactions do these files contain and is there any way to figure out how many there are without parsing?
1 Answer
No. blk*.dat
files are limited by actual size on disk, not number of transactions. Blocks are added to them until they reach a maximum size, not whether they exceed a block or transaction count. As transaction sizes are variable, it is not possible to know how many transactions are in a blk*.dat
file without having parsed it first.
However, as Bitcoin Core has already done that parsing for you, you can use the LevelDB database that it creates which contains that information. This answer provides an explanation of the format of the LevelDB records in the block index (the database stored in blocks/index
).
-
Oh so two differently speced systems would have different blk files ? Commented Sep 5, 2022 at 8:02
-
2The size of BLK files is 128MB max on any system regardless of specification. However even two identically specified systems would have BLK files whose contents differ due to receiving data in different order and due to differing stale blocks. Early BLK files contain many blocks, each with few transactions. Recent: the reverse Commented Sep 5, 2022 at 8:46