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

Function BlockGetMerkleBranch

src/test/merkle_tests.cpp:158–170  ·  view source on GitHub ↗

Older version of the merkle branch computation code, for comparison.

Source from the content-addressed store, hash-verified

156
157// Older version of the merkle branch computation code, for comparison.
158static std::vector<uint256> BlockGetMerkleBranch(const CBlock& block, const std::vector<uint256>& vMerkleTree, int nIndex)
159{
160 std::vector<uint256> vMerkleBranch;
161 int j = 0;
162 for (int nSize = block.vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
163 {
164 int i = std::min(nIndex^1, nSize-1);
165 vMerkleBranch.push_back(vMerkleTree[j+i]);
166 nIndex >>= 1;
167 j += nSize;
168 }
169 return vMerkleBranch;
170}
171
172static inline int ctz(uint32_t i) {
173 if (i == 0) return 0;

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 2

sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected