<p>The constant is called <code>MAX_BLOCKFILE_SIZE</code> and is set in <code>src/validation.h</code>.  It is currently set to <code>0x8000000</code> which is 128 <a href="https://en.wikipedia.org/wiki/Mebibyte" rel="noreferrer">MiB</a> (134,217,728 bytes).  </p>

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

<p>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.</p>

CC BY-SA 3.0
2017-01-10T16:10:10.287Z
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
CC BY-SA 3.0
2017-01-10T15:29:43.673Z
2017-01-10T15:29:43.673Z
Nate Eldredge
<p>I understand that blocks are stored on disk across multiple <code>blk*.dat</code> files, but why is the maximum file size roughly <strong>134,200,000 bytes</strong>?</p>

<ul>
<li>What's the reason behind this file size?</li>
<li>Where can I find this setting in the source code?</li>
<li>What's the exact maximum size?</li>
</ul>

<bitcoin-core-development><database><storage-footprint>
Why are blk*.dat files ~134200000 bytes?
inersha
# Why are blk*.dat files ~134200000 bytes?

(Asked by: username_0 on 2017-01-10)

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?

**Tags:** bitcoin-core-development, database, storage-footprint


---

## 1 answers

### Answer by username_1 on 2017-01-10. Score: 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](https://en.wikipedia.org/wiki/Mebibyte) (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.

> **Comments:**
> **username_2**: 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.  

---

