1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2025-01-22 13:40:58 +00:00

Made changes to ch08.asciidoc

This commit is contained in:
myarbrough@oreilly.com 2014-11-18 11:23:40 -08:00
parent ff7716acb0
commit 377b7a4ff3

View File

@ -490,12 +490,12 @@ To give a simple analogy, imagine a game where players throw a pair of dice repe
In <<sha256_example_generator_output>>, the winning "nonce" is 13 and this result can be confirmed by anyone independently. Anyone can add the number 13 as a suffix to the phrase "I am Satoshi Nakamoto" and compute the hash, verifying that it is less than the target. The successful result is also proof of work, because it proves we did the work to find that nonce. While it only takes one hash computation to verify, it took us 13 hash computations to find a nonce that worked. If we had a lower target (higher difficulty) it would take many more hash computations to find a suitable nonce, but only one hash computation for anyone to verify. Furthermore, by knowing the target, anyone can estimate the difficulty using statistics and therefore know how much work was needed to find such a nonce.
Bitcoin's Proof-Of-Work is very similar to the challenge shown in <<sha256_example_generator_output>>. The miner constructs a candidate block filled with transactions. Next, the miner calculates the hash of this block's header and sees if it is smaller than the current _target_. If the hash is not less than the target, the miner will modify the nonce (usually just incrementing it by one) and try again. At the current difficulty in the bitcoin network, miners have to try quadrillions of times before finding a nonce that results in a low enough block header hash.
Bitcoin's proof of work is very similar to the challenge shown in <<sha256_example_generator_output>>. The miner constructs a candidate block filled with transactions. Next, the miner calculates the hash of this block's header and sees if it is smaller than the current _target_. If the hash is not less than the target, the miner will modify the nonce (usually just incrementing it by one) and try again. At the current difficulty in the bitcoin network, miners have to try quadrillions of times before finding a nonce that results in a low enough block header hash.
A very simplified proof-of-work algorithm is implemented in Python in <<pow_example1>>.((("proof of work")))
A very simplified Proof-Of-Work algorithm is implemented in Python in <<pow_example1>>.
((("proof of work")))
[[pow_example1]]
.Simplified Proof-Of-Work implementation
.Simplified proof-of-work implementation
====
[source, python]
----
@ -506,7 +506,7 @@ include::code/proof-of-work-example.py[]
Running this code, you can set the desired difficulty (in bits, how many of the leading bits must be zero) and see how long it takes for your computer to find a solution. In <<pow_example_outputs>>, you can see how it works on an average laptop.
[[pow_example_outputs]]
.Running the Proof-Of-Work example for various difficulties
.Running the proof of work example for various difficulties
====
[source, bash]
----