diff --git a/ch07.asciidoc b/ch07.asciidoc index aa931c41..71b5bd05 100644 --- a/ch07.asciidoc +++ b/ch07.asciidoc @@ -34,7 +34,7 @@ A block is a container data structure that aggregates transactions for inclusion The block header consists of three sets of block metadata. First, there is a reference to a previous block hash, which connects this block to the previous block in the blockchain. We will examine this in more detail in <>. The second set of metadata, namely the difficulty, timestamp and nonce, relate to the mining competition, as detailed in <>. The third piece of metadata is the Merkle Tree root, a data structure used to efficiently summarize all the transactions in the block. -[[block_structure]] +[[block_header_structure]] .The structure of the block header [options="header"] |======= diff --git a/ch08.asciidoc b/ch08.asciidoc index 3a2eb225..d2b0ccfe 100644 --- a/ch08.asciidoc +++ b/ch08.asciidoc @@ -299,10 +299,14 @@ The next step is to summarize all the transactions with a Merkle Tree, in order The mining node will then add a 4-byte timestamp, encoded as a Unix "Epoch" timestamp, which is based on the number of seconds elapsed from January 1st, 1970, midnight UTC/GMT. The time +1388185914+ is equal to Friday, 27 Dec 2013, 23:11:54 UTC/GMT. -Finally, the node fills in the difficulty target, which defines the required proof-of-work difficulty to make this a valid block. The difficulty is stored in the block as a "difficulty bits" metric, which is a mantissa-exponent encoding of the target. The encoding has a one-byte exponent, followed by a 3 byte mantissa (coefficient). In block 277,316, for example, the difficulty bits value is +0x1903a30c+. The first part +0x19+ is a hexadecimal exponent, while the next part +0x03a30c+ is the coefficient. The concept of a difficulty target is explained in <> and the "difficulty bits" representation is explained in <>. +The node then fills in the difficulty target, which defines the required proof-of-work difficulty to make this a valid block. The difficulty is stored in the block as a "difficulty bits" metric, which is a mantissa-exponent encoding of the target. The encoding has a one-byte exponent, followed by a 3 byte mantissa (coefficient). In block 277,316, for example, the difficulty bits value is +0x1903a30c+. The first part +0x19+ is a hexadecimal exponent, while the next part +0x03a30c+ is the coefficient. The concept of a difficulty target is explained in <> and the "difficulty bits" representation is explained in <>. + +The final field is the nonce, which is initialized to zero. + +With all the other fields filled, the block header is now complete and the process of mining can begin. The goal is now to find a value for the nonce that results in a block header hash that is less than the difficulty target. The mining node will need to test billions or trillions of nonce values before a nonce is found that satisfies the requirement. [[mining]] -=== Proof-of-Work (Mining) and Consensus +=== Proof-of-Work (Mining) ((("Mining", "Proof of Work", "SHA256", "hashing power", "difficulty", "nonce"))) Mining is the process by which new bitcoin is added to the money supply. Mining also serves to secure the bitcoin system against fraudulent transactions or transactions spending the same amount of bitcoin more than once, known as a double-spend. Miners act as a decentralized clearinghouse, validating new transactions and recording them on the global ledger. A new block, containing transactions which occurred since the last block, is "mined" every 10 minutes thereby adding those transactions to the blockchain. Transactions that become part of a block and added to the blockchain are considered "confirmed", which allows the new owners of bitcoin to spend the bitcoin they received in those transactions. Miners receive two types of reward for mining: new coins created with each new block and transaction fees from all the transactions included in the block. To earn this reward, the miners compete to solve a difficult mathematical problem based on a cryptographic hash algorithm. The solution to the problem, called the Proof-of-Work, is included in the new block and acts as proof that the miner expended significant computing effort. The competition to solve the Proof-of-Work algorithm to earn reward and the right to record transactions on the blockchain is the basis for bitcoin's security model.