MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FindScriptPubKey

Function FindScriptPubKey

src/rpc/blockchain.cpp:2066–2092  ·  view source on GitHub ↗

Search for a given set of pubkey scripts

Source from the content-addressed store, hash-verified

2064
2065//! Search for a given set of pubkey scripts
2066bool FindScriptPubKey(std::atomic<int>& scan_progress, const std::atomic<bool>& should_abort, int64_t& count, CCoinsViewCursor* cursor, const std::set<CScript>& needles, std::map<COutPoint, Coin>& out_results) {
2067 scan_progress = 0;
2068 count = 0;
2069 while (cursor->Valid()) {
2070 COutPoint key;
2071 Coin coin;
2072 if (!cursor->GetKey(key) || !cursor->GetValue(coin)) return false;
2073 if (++count % 8192 == 0) {
2074 boost::this_thread::interruption_point();
2075 if (should_abort) {
2076 // allow to abort the scan via the abort reference
2077 return false;
2078 }
2079 }
2080 if (count % 256 == 0) {
2081 // update progress reference every 256 item
2082 uint32_t high = 0x100 * *key.hash.begin() + *(key.hash.begin() + 1);
2083 scan_progress = (int)(high * 100.0 / 65536.0 + 0.5);
2084 }
2085 if (needles.count(coin.out.scriptPubKey)) {
2086 out_results.emplace(key, coin);
2087 }
2088 cursor->Next();
2089 }
2090 scan_progress = 100;
2091 return true;
2092}
2093
2094/** RAII object to prevent concurrency issue when scanning the txout set */
2095static std::mutex g_utxosetscan;

Callers 1

scantxoutsetFunction · 0.85

Calls 6

ValidMethod · 0.45
GetKeyMethod · 0.45
GetValueMethod · 0.45
beginMethod · 0.45
countMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected