mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-01 21:17:13 +00:00
Fix a bogus comment in checkMerkleBranch().
This commit is contained in:
@@ -301,17 +301,16 @@ public class Block extends Message {
|
|||||||
// derive the root, which can be checked against the block header. These proofs aren't used right now but
|
// derive the root, which can be checked against the block header. These proofs aren't used right now but
|
||||||
// will be helpful later when we want to download partial block contents.
|
// will be helpful later when we want to download partial block contents.
|
||||||
//
|
//
|
||||||
// Note that if the number of transactions is not a power of two the last tx is repeated to make it so (see
|
// Note that if the number of transactions is not even the last tx is repeated to make it so (see
|
||||||
// tx3 above). A tree with 5 transactions would look like this:
|
// tx3 above). A tree with 5 transactions would look like this:
|
||||||
//
|
//
|
||||||
// root
|
// root
|
||||||
// / \
|
// / \
|
||||||
// / \
|
// 1 \
|
||||||
// 1 6
|
// / \ \
|
||||||
// / \ / \
|
// 2 3 4
|
||||||
// 2 3 4 5
|
// / \ / \ / \
|
||||||
// / \ / \ / \ / \
|
// t1 t2 t3 t4 t5 t5
|
||||||
// t1 t2 t3 t4 t5 t5 t5 t5
|
|
||||||
ArrayList<byte[]> tree = new ArrayList<byte[]>();
|
ArrayList<byte[]> tree = new ArrayList<byte[]>();
|
||||||
// Start by adding all the hashes of the transactions as leaves of the tree.
|
// Start by adding all the hashes of the transactions as leaves of the tree.
|
||||||
for (Transaction t : transactions) {
|
for (Transaction t : transactions) {
|
||||||
@@ -323,7 +322,7 @@ public class Block extends Message {
|
|||||||
// For each pair of nodes on that level:
|
// For each pair of nodes on that level:
|
||||||
for (int left = 0; left < levelSize; left += 2) {
|
for (int left = 0; left < levelSize; left += 2) {
|
||||||
// The right hand node can be the same as the left hand, in the case where we don't have enough
|
// The right hand node can be the same as the left hand, in the case where we don't have enough
|
||||||
// transactions to be a power of two.
|
// transactions.
|
||||||
int right = Math.min(left + 1, levelSize - 1);
|
int right = Math.min(left + 1, levelSize - 1);
|
||||||
byte[] leftBytes = Utils.reverseBytes(tree.get(levelOffset + left));
|
byte[] leftBytes = Utils.reverseBytes(tree.get(levelOffset + left));
|
||||||
byte[] rightBytes = Utils.reverseBytes(tree.get(levelOffset + right));
|
byte[] rightBytes = Utils.reverseBytes(tree.get(levelOffset + right));
|
||||||
|
|||||||
Reference in New Issue
Block a user