mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-12-23 15:18:11 +00:00
Made changes to ch07.asciidoc
This commit is contained in:
parent
1117fc2efb
commit
cb3d4e28ad
@ -157,6 +157,10 @@ Merkle trees are used in bitcoin to summarize all the transactions in a block, p
|
||||
|
||||
When N data elements are hashed and summarized in a merkle tree, you can check to see if any one data element is included in the tree with at most +2*log~2~(N)+ calculations, making this a very efficient data structure.
|
||||
|
||||
[[chain_of_blocks]]
|
||||
.Blocks linked in a chain, by reference to the previous block header hash
|
||||
image::images/msbt_0701.png[]
|
||||
|
||||
The merkle tree is constructed bottom-up. In the following example, we start with four transactions, A, B, C and D, which form the _leaves_ of the Merkle tree, as shown in <<simple_merkle>>. The transactions are not stored in the merkle tree; rather, their data is hashed and the resulting hash is stored in each leaf node as H~A~, H~B~, H~C~, and H~D~:
|
||||
|
||||
----
|
||||
@ -171,10 +175,6 @@ H~AB~ = SHA256(SHA256(H~A~ + H~B~))
|
||||
|
||||
The process continues until there is only one node at the top, the node known as the Merkle root. That 32-byte hash is stored in the block header and summarizes all the data in all four transactions.
|
||||
|
||||
[[chain_of_blocks]]
|
||||
.Blocks linked in a chain, by reference to the previous block header hash
|
||||
image::images/msbt_0701.png[]
|
||||
|
||||
[[simple_merkle]]
|
||||
.Calculating the nodes in a merkle tree
|
||||
image::images/msbt_0702.png["merkle_tree"]
|
||||
|
Loading…
Reference in New Issue
Block a user