Bitcoin Forum
May 11, 2024, 01:30:56 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: About the block.nBits  (Read 3376 times)
esuncloud (OP)
Member
**
Offline Offline

Activity: 98
Merit: 10


View Profile
July 21, 2013, 02:24:55 AM
 #1

Beginner's question..
I got that how to convert block.nBits to difficulty, but how hash rates impact the block.nBits?
I know CBigNum().SetCompact(block.nBits).getuint256() to set the target hash, but what does exactly SetCompact mean and what's the range of nBits.
Last question why block.nBits    = 0x1d00ffff in genesis block?
Thanks for your help..
The trust scores you see are subjective; they will change depending on who you have in your trust list.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715434256
Hero Member
*
Offline Offline

Posts: 1715434256

View Profile Personal Message (Offline)

Ignore
1715434256
Reply with quote  #2

1715434256
Report to moderator
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
July 21, 2013, 08:39:21 AM
 #2

SetCompact sort of compresses the big 256 integer into a 32 bit value.

0x1d00ffff is the reference value that represents difficulty 1.
It basically stands for:
Code:
0x1d00ffff
nSize = 0x1d
nWord = 0xfffff
Target = nWord << ( 8 * (nSize-3) )
Target = 0xfffff << (8 * 26)
So Bits=0x1d00ffff adds up to the Target of 00000000ffff0000000000000000000000000000000000000000000000000000

If you'd take the current bits; 436249641 = 0x1A00A429, you get a target:
Code:
0xA429 << ( 8 * (0x1A-3) ) => 00000000000000a4290000000000000000000000000000000000000000000000

A new (mined) block must have a hash value lower from the current target, in order for it to get accepted by the network.
Hash rates impact the block.nBits in a way that each 2016 blocks new target value (encoded in Bits) for the next 2016 blocks is calculated - and then enforced while verifying blocks.
The idea is that there should be exactly 2 weeks difference in the timestamps of the two blocks that are 2016 apart - if the difference was longer the target value is decreased, if shorter - increased, always proportionally.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
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!