refactor: use Hash helper for double-SHA256 calculations

This commit is contained in:
Sebastian Falbesoner
2023-01-31 19:34:35 +01:00
parent b5868f4b1f
commit 87f11ef47f
5 changed files with 8 additions and 23 deletions

View File

@@ -60,7 +60,7 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
}
}
mutated |= (inner[level] == h);
CHash256().Write(inner[level]).Write(h).Finalize(h);
h = Hash(inner[level], h);
}
// Store the resulting hash at inner position level.
inner[level] = h;
@@ -86,7 +86,7 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
if (pbranch && matchh) {
pbranch->push_back(h);
}
CHash256().Write(h).Write(h).Finalize(h);
h = Hash(h, h);
// Increment count to the value it would have if two entries at this
// level had existed.
count += ((uint32_t{1}) << level);
@@ -101,7 +101,7 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
matchh = true;
}
}
CHash256().Write(inner[level]).Write(h).Finalize(h);
h = Hash(inner[level], h);
level++;
}
}