MCPcopy Create free account
hub / github.com/ElementsProject/elements / ComputeMerkleRootFromBranch

Function ComputeMerkleRootFromBranch

src/test/merkle_tests.cpp:12–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10BOOST_FIXTURE_TEST_SUITE(merkle_tests, TestingSetup)
11
12static 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. */
26static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) {

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 3

HashFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected