Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: spencerdupre on August 19, 2015, 05:15:29 AM



Title: How important is GetMedianTimePast in UpdateTime ?
Post by: spencerdupre on August 19, 2015, 05:15:29 AM
Trying to learn more about the code, and producing some altcoins with modifications to test.  I've got one with Devcoin merged mining patches applied, trying to merge mine it with Bitcoin.  During merged mining, but not single coin mining, it produces rejected blocks which have timestamps either years in the past, or decades in the future (usually the latter).  I tracked it down to UpdateTime, and GetMedianTimePast.  UpdateTime returns the max of GetMedianTimePast, and GetAdjustedTime.  Sometimes, GetMedianTimePast returns wildly high positive numbers, though usually it produces wildly low negative numbers.  If they're positive, they're the max(), and become the new timestamp.  So I've cut GetMedianTimePast out of UpdateTime:

Code:
//    block.nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
    block.nTime = GetAdjustedTime();

Are there any major consequences to doing this?

Alternatively, if you have any ideas why GetMedianTimePast is producing numbers like -6969792509024063232 and 441414620544770536, that would also be super helpful.