Bitcoin Forum
May 12, 2024, 12:43:37 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: "12. Check that nBits value matches the difficulty rules"  (Read 1706 times)
bitcoinandroid (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
October 31, 2011, 05:12:18 AM
 #1

I have a beginner question on this rule:

"12. Check that nBits value matches the difficulty rules"
https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages

I understand how to convert the nBits to a difficulty.  But what does "match the difficulty rules" means?

I'm assuming this means check if the difficulty the block is using seems reasonable.  But do we have to calculate what the difficulty should be for any given block, and if so how?  I was trying to find some sample code for this but came up empty handed.

Google turned up this but I'm afraid I'm not really understanding what it does:
https://github.com/bitcoin/bitcoin/blob/master/src/bitcoinrpc.cpp#L203

Many thanks for a point in the right direction!
1715474617
Hero Member
*
Offline Offline

Posts: 1715474617

View Profile Personal Message (Offline)

Ignore
1715474617
Reply with quote  #2

1715474617
Report to moderator
1715474617
Hero Member
*
Offline Offline

Posts: 1715474617

View Profile Personal Message (Offline)

Ignore
1715474617
Reply with quote  #2

1715474617
Report to moderator
You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715474617
Hero Member
*
Offline Offline

Posts: 1715474617

View Profile Personal Message (Offline)

Ignore
1715474617
Reply with quote  #2

1715474617
Report to moderator
1715474617
Hero Member
*
Offline Offline

Posts: 1715474617

View Profile Personal Message (Offline)

Ignore
1715474617
Reply with quote  #2

1715474617
Report to moderator
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
October 31, 2011, 11:22:06 AM
 #2

A block is not USING a difficulty, it's at SOME difficulty regardless if it wants to or not.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
genjix
Legendary
*
expert
Offline Offline

Activity: 1232
Merit: 1076


View Profile
October 31, 2011, 11:45:46 AM
 #3

you go to the previous block and find what the next difficulty should be. the bits returned should be the same as the current block's bits.

the function is called GetNextWorkRequired and it takes the previous block to the current one as an argument
bitcoinandroid (OP)
Newbie
*
Offline Offline

Activity: 37
Merit: 0


View Profile
November 01, 2011, 02:59:49 AM
 #4

Thanks genjix!  That was what I was looking for.  Much appreciated.   Grin
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!