Bitcoin Forum
May 14, 2024, 02:29:20 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Little help calculating difficulty  (Read 945 times)
brian_armstrong (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 0


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

Posts: 1715653760

View Profile Personal Message (Offline)

Ignore
1715653760
Reply with quote  #2

1715653760
Report to moderator
1715653760
Hero Member
*
Offline Offline

Posts: 1715653760

View Profile Personal Message (Offline)

Ignore
1715653760
Reply with quote  #2

1715653760
Report to moderator
1715653760
Hero Member
*
Offline Offline

Posts: 1715653760

View Profile Personal Message (Offline)

Ignore
1715653760
Reply with quote  #2

1715653760
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715653760
Hero Member
*
Offline Offline

Posts: 1715653760

View Profile Personal Message (Offline)

Ignore
1715653760
Reply with quote  #2

1715653760
Report to moderator
1715653760
Hero Member
*
Offline Offline

Posts: 1715653760

View Profile Personal Message (Offline)

Ignore
1715653760
Reply with quote  #2

1715653760
Report to moderator
1715653760
Hero Member
*
Offline Offline

Posts: 1715653760

View Profile Personal Message (Offline)

Ignore
1715653760
Reply with quote  #2

1715653760
Report to moderator
brian_armstrong (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 0


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!