Title: Little help calculating difficulty Post by: brian_armstrong on December 28, 2011, 03:46:43 AM Hi,
My GetNextWorkRequired calculation seems to be failing on Block 40,319 (previous ones worked fine) Block 40,320 should go to 0x1c654657 difficulty bits, but my calculation is coming to 0x1d006546 Can anyone see what I'm doing wrong here? I based this on GetNextWorkRequired in https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L762 : ============== Block 38,304 has time 1265319794 http://blockexplorer.com/b/38304 Block 40,319 has time 1266190073 http://blockexplorer.com/b/40319 actual = 1266190073 - 1265319794 actual = 870279 target = 1209600 (two weeks) (didn't change more than 4x or 1/4 of target so no adjustment needed here) Block 40,319 has difficulty 486575299 which decodes to "000000008cc30000000000000000000000000000000000000000000000000000" retarget = 0x000000008cc30000000000000000000000000000000000000000000000000000 * actual / target retarget = 0x00000000654657a76a76a76a76a76a76a76a76a76a76a76a76a76a76a76a76a7 encoding retarget back to bits gives 486565190 or 0x1d006546 Any ideas? Really appreciate it - thanks! Title: Re: Little help calculating difficulty Post by: brian_armstrong on December 29, 2011, 07:43:47 PM Figured it out - it was a problem with how I was converting to compact form.
|