Why are blk*.dat files ~134200000 bytes?



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?


Posted 2017-01-10T13:33:46.877

Reputation: 2 618



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.

Nate Eldredge

Posted 2017-01-10T13:33:46.877

Reputation: 22 182

3The 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 – 2017-01-10T16:10:10.287