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

Method CMerkleBlock

src/merkleblock.cpp:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter* filter, const std::set<uint256>* txids)
31{
32 header = block.GetBlockHeader();
33
34 std::vector<bool> vMatch;
35 std::vector<uint256> vHashes;
36
37 vMatch.reserve(block.vtx.size());
38 vHashes.reserve(block.vtx.size());
39
40 for (unsigned int i = 0; i < block.vtx.size(); i++)
41 {
42 const uint256& hash = block.vtx[i]->GetHash();
43 if (txids && txids->count(hash)) {
44 vMatch.push_back(true);
45 } else if (filter && filter->IsRelevantAndUpdate(*block.vtx[i])) {
46 vMatch.push_back(true);
47 vMatchedTxn.emplace_back(i, hash);
48 } else {
49 vMatch.push_back(false);
50 }
51 vHashes.push_back(hash);
52 }
53
54 txn = CPartialMerkleTree(vHashes, vMatch);
55}
56
57uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector<uint256> &vTxid) {
58 //we can never have zero txs in a merkle block, we always need the coinbase tx

Callers

nothing calls this directly

Calls 9

countMethod · 0.80
IsRelevantAndUpdateMethod · 0.80
emplace_backMethod · 0.80
CPartialMerkleTreeClass · 0.70
GetBlockHeaderMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
GetHashMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected