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?

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
    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. – Pieter Wuille Jan 10 '17 at 16:10

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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