1

I know how to calculate difficulty, and I know it is increased or decreased by checking the timespan of the past 2016 blocks.

and I found actual code for calculating timespan: https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp#L55

actual_timespan = last_block->get_timestamp() - first_block->get_timestamp()

But, as I know timestamp in block is not the exact time of the mining: https://en.bitcoin.it/wiki/Block_timestamp

So, the timespan which is used to calculate the next difficulty is not the exact timespan but approximate value. Am I right?

0

It is impossible to know that actual timespan due to network delays, malicious miner behavior, being offline, etc. The target readjustment just uses the closest thing it can get to the actual timespan which is the difference in the timestamps. However those timestamps can be faked as well, so it is just an estimate.

  • You are right. but I just want to make sure that timestamp is also very inaccurate. not only because of network delays, malicious behavior, offline, but also because of choosing rules of timestamp – Hyun Seok Jeong Sep 12 '18 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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