2

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 1

4

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).

2
  • Oh so two differently speced systems would have different blk files ? Sep 5, 2022 at 8:02
  • 2
    The 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 Sep 5, 2022 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.