MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckBlockFilterMatches

Function CheckBlockFilterMatches

src/rpc/blockchain.cpp:2517–2540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2515};
2516
2517static bool CheckBlockFilterMatches(BlockManager& blockman, const CBlockIndex& blockindex, const GCSFilter::ElementSet& needles)
2518{
2519 const CBlock block{GetBlockChecked(blockman, blockindex)};
2520 const CBlockUndo block_undo{GetUndoChecked(blockman, blockindex)};
2521
2522 // Check if any of the outputs match the scriptPubKey
2523 for (const auto& tx : block.vtx) {
2524 if (std::any_of(tx->vout.cbegin(), tx->vout.cend(), [&](const auto& txout) {
2525 return needles.contains(std::vector<unsigned char>(txout.scriptPubKey.begin(), txout.scriptPubKey.end()));
2526 })) {
2527 return true;
2528 }
2529 }
2530 // Check if any of the inputs match the scriptPubKey
2531 for (const auto& txundo : block_undo.vtxundo) {
2532 if (std::any_of(txundo.vprevout.cbegin(), txundo.vprevout.cend(), [&](const auto& coin) {
2533 return needles.contains(std::vector<unsigned char>(coin.out.scriptPubKey.begin(), coin.out.scriptPubKey.end()));
2534 })) {
2535 return true;
2536 }
2537 }
2538
2539 return false;
2540}
2541
2542static RPCMethod scanblocks()
2543{

Callers 1

scanblocksFunction · 0.85

Calls 8

GetBlockCheckedFunction · 0.85
GetUndoCheckedFunction · 0.85
any_ofClass · 0.85
cbeginMethod · 0.45
cendMethod · 0.45
containsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected