Changeset View
Changeset View
Standalone View
Standalone View
src/merkleblock.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, | ||||
if (height == 0) { | if (height == 0) { | ||||
// hash at height 0 is the txids themself. | // hash at height 0 is the txids themself. | ||||
return vTxid[pos]; | return vTxid[pos]; | ||||
} | } | ||||
// Calculate left hash. | // Calculate left hash. | ||||
uint256 left = CalcHash(height - 1, pos * 2, vTxid), right; | uint256 left = CalcHash(height - 1, pos * 2, vTxid), right; | ||||
// Calculate right hash if not beyond the end of the array - copy left hash | // Calculate right hash if not beyond the end of the array - copy left hash | ||||
// otherwise1. | // otherwise. | ||||
if (pos * 2 + 1 < CalcTreeWidth(height - 1)) { | if (pos * 2 + 1 < CalcTreeWidth(height - 1)) { | ||||
right = CalcHash(height - 1, pos * 2 + 1, vTxid); | right = CalcHash(height - 1, pos * 2 + 1, vTxid); | ||||
} else { | } else { | ||||
right = left; | right = left; | ||||
} | } | ||||
// Combine subhashes. | // Combine subhashes. | ||||
return Hash(BEGIN(left), END(left), BEGIN(right), END(right)); | return Hash(BEGIN(left), END(left), BEGIN(right), END(right)); | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |