8

I understand that blocks are stored on disk across multiple blk*.dat files, but why is the maximum file size roughly 134,200,000 bytes?

  • What's the reason behind this file size?
  • Where can I find this setting in the source code?
  • What's the exact maximum size?

1 Answer 1

9

The constant is called MAX_BLOCKFILE_SIZE and is set in src/validation.h. It is currently set to 0x8000000 which is 128 MiB (134,217,728 bytes).

You can see where it is checked in FindBlockPos() in src/validation.cpp.

There isn't any indication of why this specific size was chosen and it may be arbitrary. It is desirable to have some limit because some operating systems (or specific filesystems) have limits on maximum file size, usually above 2 GB or so. So at least this limit ensures we never get anywhere close to an OS limit.

1
  • 4
    The rarionale is to enable pruning. We always delete full block files at once, as soon as all blocks in it are old enough. Larger files are more efficient on disk, but have more overhead for pruning, due to delaying when the older blocks in a file are removed. Jan 10, 2017 at 16:10

Your Answer

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

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