Bitcoin Forum
December 03, 2016, 01:41:37 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Little help calculating difficulty  (Read 746 times)
brian_armstrong
Newbie
*
Offline Offline

Activity: 29


View Profile
December 28, 2011, 03:46:43 AM
 #1

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!
1480772497
Hero Member
*
Offline Offline

Posts: 1480772497

View Profile Personal Message (Offline)

Ignore
1480772497
Reply with quote  #2

1480772497
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
brian_armstrong
Newbie
*
Offline Offline

Activity: 29


View Profile
December 29, 2011, 07:43:47 PM
 #2

Figured it out - it was a problem with how I was converting to compact form.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!