38 static void MerkleComputation(
const std::vector<uint256>& leaves,
uint256* proot,
bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) {
39 if (pbranch) pbranch->clear();
40 if (leaves.size() == 0) {
41 if (pmutated) *pmutated =
false;
57 while (count < leaves.size()) {
59 bool matchh = count == branchpos;
65 for (level = 0; !(count & (((uint32_t)1) << level)); level++) {
68 pbranch->push_back(inner[level]);
69 }
else if (matchlevel == level) {
70 pbranch->push_back(h);
74 mutated |= (inner[level] == h);
89 while (!(count & (((uint32_t)1) << level))) {
93 bool matchh = matchlevel == level;
94 while (count != (((uint32_t)1) << level)) {
98 if (pbranch && matchh) {
99 pbranch->push_back(h);
104 count += (((uint32_t)1) << level);
107 while (!(count & (((uint32_t)1) << level))) {
110 pbranch->push_back(inner[level]);
111 }
else if (matchlevel == level) {
112 pbranch->push_back(h);
121 if (pmutated) *pmutated = mutated;
122 if (proot) *proot = h;
127 MerkleComputation(leaves, &hash, mutated, -1, NULL);
132 std::vector<uint256> ret;
133 MerkleComputation(leaves, NULL, NULL, position, &ret);
139 for (std::vector<uint256>::const_iterator it = vMerkleBranch.begin(); it != vMerkleBranch.end(); ++it) {
152 std::vector<uint256> leaves;
153 leaves.resize(block.
vtx.size());
154 for (
size_t s = 0; s < block.
vtx.size(); s++) {
155 leaves[s] = block.
vtx[s].GetHash();
162 std::vector<uint256> leaves;
163 leaves.resize(block.
vtx.size());
164 for (
size_t s = 0; s < block.
vtx.size(); s++) {
165 leaves[s] = block.
vtx[s].GetHash();