novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

getMedianTimestampOfRecentBlocks not always valid #370

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In AbstractBlockChain.java, the getMedianTimestampOfRecentBlocks method should 
return the median timestamp. I have discovered a minor bug in the code though 
the final timestamp never gets sorted into position. This could potentially 
invalidate a valid block and freeze blockchains. The solution is to change 

Arrays.sort(timestamps, unused+1, 10);

to

Arrays.sort(timestamps, unused+1, 11);

Original issue reported on code.google.com by mastersc...@gmail.com on 27 Mar 2013 at 3:52

GoogleCodeExporter commented 9 years ago
Thanks! CCd Matt for a quick review.

Original comment by hearn@google.com on 27 Mar 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Great catch.

Original comment by hearn@google.com on 29 Mar 2013 at 5:56

GoogleCodeExporter commented 9 years ago
This issue was closed by revision a78b53c5aaff.

Original comment by hearn@google.com on 29 Mar 2013 at 6:19