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

Function FindAndDelete

src/script/interpreter.cpp:349–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349int FindAndDelete(CScript& script, const CScript& b)
350{
351 int nFound = 0;
352 if (b.empty())
353 return nFound;
354 CScript result;
355 CScript::const_iterator pc = script.begin(), pc2 = script.begin(), end = script.end();
356 opcodetype opcode;
357 do
358 {
359 result.insert(result.end(), pc2, pc);
360 while (static_cast<size_t>(end - pc) >= b.size() && std::equal(b.begin(), b.end(), pc))
361 {
362 pc = pc + b.size();
363 ++nFound;
364 }
365 pc2 = pc;
366 }
367 while (script.GetOp(pc, opcode));
368
369 if (nFound > 0) {
370 result.insert(result.end(), pc2, end);
371 script = std::move(result);
372 }
373
374 return nFound;
375}
376
377namespace {
378/** A data type to abstract out the condition stack during script execution.

Callers 5

EvalChecksigPreTapscriptFunction · 0.70
EvalScriptFunction · 0.70
SignatureHashOldFunction · 0.50
BOOST_AUTO_TEST_CASEFunction · 0.50
FUZZ_TARGET_INITFunction · 0.50

Calls 6

GetOpMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45

Tested by 3

SignatureHashOldFunction · 0.40
BOOST_AUTO_TEST_CASEFunction · 0.40
FUZZ_TARGET_INITFunction · 0.40