<p>You must have read <a href="http://www.age-of-bitcoin.com/dynamic-block-size-cap-scaling/" rel="nofollow">this article</a> and are looking to implement dynamic block size limits. You should know that it's not just a simple formula though that only affects one piece of code, it's more complicated than that.</p>

<p>I know of a few coins that have done this. Monero, Cryptonote, and ziftrCOIN. The latter is the one I am the most familiar with, so I'll explain how the solution works.</p>

<p>First, the block size and chain size is <a href="https://github.com/ZiftrCOIN/ziftrcoin/blob/v0.9.31/src/main.h#L723-L731" rel="nofollow">added to the block index</a>. Then, whenever the <a href="https://github.com/ZiftrCOIN/ziftrcoin/blob/v0.9.31/src/main.cpp#L423-L491" rel="nofollow">tip of the chain is updated</a>, the code checks, once every 3 months, to see if both:</p>

<ul>
<li>The average block size is greater than 2/3 of the current limit.</li>
<li>The median block size is greater than 1/2 of the current limit.</li>
</ul>

<p>If both are true, then it allows the maximum block size to increase by 10%. If this happened regularly for 2 years, the maximum block size would approximately double. </p>

CC BY-SA 3.0
2015-03-20T21:13:51.123Z
Be careful with solutions like that, it sounds easily manipulated, and the problems introduced could be worse than the ones it is trying to solve :p Just kidding, thanks I will use the Ziftr code!
Maestro
CC BY-SA 3.0
2015-03-20T21:49:21.957Z
@Muis, Haha, that's good advice :P One of the main arguments I've heard against dynamic block sizes limit is that miners could form these 'cartels' and block other miners from participating by forcing extremely large block sizes. But a few pool operators could do this anyway by colluding to only mine on top of each others blocks.
morsecoder
CC BY-SA 3.0
2015-03-20T22:38:15.563Z
Why does ZiftrCOIN check both the average and median? It seems like in all circumstances where the average is greater than 2/3 the limit, the median is also greater than 1/2 the limit.
Nick ODell
CC BY-SA 3.0
2015-03-20T16:26:06.547Z
2015-03-20T16:26:06.547Z
morsecoder
<p>I want to implement this, so does anyone have a formula for adaptive blocksize?</p>

<p>I only found this:</p>

<pre><code>if(average size of last 4096 blocks*4&gt;maxblocksize &amp;&amp; 
   median size of last 4096 blocks *8&gt;maxblocksize)
        maxblocksize = (average size of last 4096 blocks*4)
</code></pre>

<protocol>
Does anyone have a formula for adaptive blocksize?
Maestro
# Does anyone have a formula for adaptive blocksize?

(Asked by: username_0 on 2015-03-20)

I want to implement this, so does anyone have a formula for adaptive blocksize?
I only found this:
if(average size of last 4096 blocks*4>maxblocksize && 
   median size of last 4096 blocks *8>maxblocksize)
        maxblocksize = (average size of last 4096 blocks*4)

**Tags:** protocol


---

## 1 answers

### Answer by username_1 on 2015-03-20. Score: 3 | Accepted answer

You must have read [this article](http://www.age-of-bitcoin.com/dynamic-block-size-cap-scaling/) and are looking to implement dynamic block size limits. You should know that it's not just a simple formula though that only affects one piece of code, it's more complicated than that.

I know of a few coins that have done this. Monero, Cryptonote, and ziftrCOIN. The latter is the one I am the most familiar with, so I'll explain how the solution works.

First, the block size and chain size is [added to the block index](https://github.com/ZiftrCOIN/ziftrcoin/blob/v0.9.31/src/main.h#L723-L731). Then, whenever the [tip of the chain is updated](https://github.com/ZiftrCOIN/ziftrcoin/blob/v0.9.31/src/main.cpp#L423-L491), the code checks, once every 3 months, to see if both:

* The average block size is greater than 2/3 of the current limit.
* The median block size is greater than 1/2 of the current limit.

If both are true, then it allows the maximum block size to increase by 10%. If this happened regularly for 2 years, the maximum block size would approximately double.

> **Comments:**
> **username_0**: Be careful with solutions like that, it sounds easily manipulated, and the problems introduced could be worse than the ones it is trying to solve :p Just kidding, thanks I will use the Ziftr code!  
> **username_1**: @Muis, Haha, that's good advice :P One of the main arguments I've heard against dynamic block sizes limit is that miners could form these 'cartels' and block other miners from participating by forcing extremely large block sizes. But a few pool operators could do this anyway by colluding to only mine on top of each others blocks.  
> **username_2**: Why does ZiftrCOIN check both the average and median? It seems like in all circumstances where the average is greater than 2/3 the limit, the median is also greater than 1/2 the limit.  

---

