Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: thebookofsouls on September 05, 2015, 03:37:24 PM



Title: Choosing the most difficult block chain when a client signs in. How?
Post by: thebookofsouls on September 05, 2015, 03:37:24 PM
In this answer: http://bitcoin.stackexchange.com/a/760/28219

It is said:

Quote
Because of all this work, when a Bitcoin client signs on to the network it can trust the block chain that was most difficult to produce (since this is evidently the one that was being worked on by the most miners).

Unfortunately there is nothing evident for me there  8)

Can someone explain how can a block chain be more difficult to solve than another one?


Title: Re: How can a block be considered more difficult to solve/hash than another one?
Post by: achow101 on September 05, 2015, 03:42:08 PM
The hash of the block must be less than the target (typically represented as having more leading 0's but that is technically incorrect). The block hash is a 256 bit number in hexadecimal form and so is the target. In order to be more difficult, the hash must be less than that target. As the difficulty increases, the target decreases, thus restricting the range of acceptable hashes. As the range decreases, it becomes more difficult to find a hash that matches the criteria.

This should help as well: https://en.bitcoin.it/wiki/Difficulty


Title: Re: How can a block be considered more difficult to solve/hash than another one?
Post by: thebookofsouls on September 05, 2015, 03:54:36 PM
The hash of the block must be less than the target (typically represented as having more leading 0's but that is technically incorrect). The block hash is a 256 bit number in hexadecimal form and so is the target. In order to be more difficult, the hash must be less than that target. As the difficulty increases, the target decreases, thus restricting the range of acceptable hashes. As the range decreases, it becomes more difficult to find a hash that matches the criteria.

This should help as well: https://en.bitcoin.it/wiki/Difficulty

I did not ask about difficulty. I asked about block comparison when there is a branch, in other words, when there are two possible block chains.

EDIT: This guy attempted to answer, but not very well.

Quote
Block difficulty is determined only by the sum speed of miners working on that chain particular chain, kept track of by evaluating the the spacing of the timestamps of blocks in a 2 week period. It's worthwhile to think about the block chain as a tree that just happens to have a very strong main branch, where branches are weighed by how much work went into creating them rather than their length.

                                                     
Quote
           +---> 9 +---> 9 
9 +----> 9 |  
           +---> 1 +---> 1 +---> 1 +---> 1 +---> 1 
            
Here we have two competing tips of the chain, one with a cumulative difficulty of 36 (9+9+9+9, and one with a cumulative difficulty of 25 (9+9+1+1+1+1+1). Although the top section of the fork has less blocks, it has a higher difficulty than the bottom fork and so is regarded as the current "best" side of the chain.



Title: Re: How can a block be considered more difficult to solve/hash than another one?
Post by: achow101 on September 05, 2015, 03:59:19 PM
The hash of the block must be less than the target (typically represented as having more leading 0's but that is technically incorrect). The block hash is a 256 bit number in hexadecimal form and so is the target. In order to be more difficult, the hash must be less than that target. As the difficulty increases, the target decreases, thus restricting the range of acceptable hashes. As the range decreases, it becomes more difficult to find a hash that matches the criteria.

This should help as well: https://en.bitcoin.it/wiki/Difficulty

I did not ask about difficulty. I asked about block comparison when there is a branch, in other words, when there are two possible block chains.


That is related to difficulty. If the difficulty for a block is higher than another block, it is more difficult. The difficulty is encoded into blocks as the "bits" field.

The longest blockchain is the blockchain with the highest combined difficulty. I think it is just the sum of all of the difficulties of all of the blocks.