| 10 | BOOST_FIXTURE_TEST_SUITE(merkle_tests, TestingSetup) |
| 11 | |
| 12 | static uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& vMerkleBranch, uint32_t nIndex) { |
| 13 | uint256 hash = leaf; |
| 14 | for (std::vector<uint256>::const_iterator it = vMerkleBranch.begin(); it != vMerkleBranch.end(); ++it) { |
| 15 | if (nIndex & 1) { |
| 16 | hash = Hash(*it, hash); |
| 17 | } else { |
| 18 | hash = Hash(hash, *it); |
| 19 | } |
| 20 | nIndex >>= 1; |
| 21 | } |
| 22 | return hash; |
| 23 | } |
| 24 | |
| 25 | /* This implements a constant-space merkle root/path calculator, limited to 2^32 leaves. */ |
| 26 | static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) { |
no test coverage detected