1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-12-11 01:08:15 +00:00

"merkle tree is a binary tree" does not automatically imply that it "needs an even number of leaf nodes". Valid binary trees may contain an odd number of leaf nodes.

This commit is contained in:
Cragin Godley 2014-10-20 01:27:29 -04:00
parent 6b386625d5
commit 9a4ca75610

View File

@ -171,7 +171,7 @@ The process continues until there is only one node at the top, the node known as
.Calculating the nodes in a Merkle Tree .Calculating the nodes in a Merkle Tree
image::images/MerkleTree.png["merkle_tree"] image::images/MerkleTree.png["merkle_tree"]
Since the merkle tree is a binary tree, it needs an even number of leaf nodes. If there is an odd number of transactions to summarize, the last transaction hash will be duplicated to create an even number of leaf nodes, also known as a _balanced tree_. This is shown in the example below, where transaction C is duplicated: If there is an odd number of transactions to summarize, the last transaction hash will be duplicated to create an even number of leaf nodes, also known as a _balanced tree_. This is shown in the example below, where transaction C is duplicated:
[[merkle_tree_odd]] [[merkle_tree_odd]]
.An even number of data elements, by duplicating one data element .An even number of data elements, by duplicating one data element