Author

Topic: About the block.nBits (Read 3375 times)

legendary
Activity: 2053
Merit: 1354
aka tonikt
July 21, 2013, 04: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.
member
Activity: 98
Merit: 10
July 20, 2013, 10:24:55 PM
#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..
Jump to: