| 43 | } |
| 44 | |
| 45 | int FindAndDelete(CScript &script, const CScript &b) { |
| 46 | int nFound = 0; |
| 47 | if (b.empty()) { |
| 48 | return nFound; |
| 49 | } |
| 50 | |
| 51 | CScript result; |
| 52 | CScript::const_iterator pc = script.begin(), pc2 = script.begin(), |
| 53 | end = script.end(); |
| 54 | opcodetype opcode; |
| 55 | do { |
| 56 | result.insert(result.end(), pc2, pc); |
| 57 | while (static_cast<size_t>(end - pc) >= b.size() && |
| 58 | std::equal(b.begin(), b.end(), pc)) { |
| 59 | pc = pc + b.size(); |
| 60 | ++nFound; |
| 61 | } |
| 62 | pc2 = pc; |
| 63 | } while (script.GetOp(pc, opcode)); |
| 64 | |
| 65 | if (nFound > 0) { |
| 66 | result.insert(result.end(), pc2, end); |
| 67 | script = std::move(result); |
| 68 | } |
| 69 | |
| 70 | return nFound; |
| 71 | } |
| 72 | |
| 73 | static void CleanupScriptCode(CScript &scriptCode, |
| 74 | const std::vector<uint8_t> &vchSig, |