The difficulty adjustment algorithm is:
block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**((block.number // 100000) - 2))
where // is the integer division operator, eg. 6 // 2 = 3, 7 // 2 = 3, 8 // 2 = 4.
From what I understand, a 10 second threshold was chosen to keep the block time in the range of 10-20 seconds. Also, the source code is available here. So, can I modify the algorithm (maybe change //10
to //5
) and create a blockchain network which takes 5 seconds
to confirm a block? Is this achievable? I hoped to get an answer to this question through this blog post but couldn't figure out the exact downfalls in doing this.
P.S: Basically, I have an application running on a private blockchain which requires less block confirmation time. I started the blockchain with low difficulty (0x400
) but it increased over time to maintain a 15 second average block time. So, I am looking for a way to prevent this difficulty from increasing. Is this possible to achieve without a compromise in security?
I'm using geth-1.4.9