| 2343 | }; |
| 2344 | |
| 2345 | static DisconnectResult ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint& out) { |
| 2346 | bool fClean = true; |
| 2347 | |
| 2348 | CCoinsModifier coins = view.ModifyCoins(out.hash); |
| 2349 | if (undo.nHeight != 0) { |
| 2350 | if (!coins->IsPruned()) { |
| 2351 | LogPrintf("%s: Avoid data that will overwrite the transaction", __func__); |
| 2352 | fClean = false; |
| 2353 | } |
| 2354 | coins->Clear(); |
| 2355 | coins->fCoinBase = undo.fCoinBase; |
| 2356 | coins->fCoinStake = undo.fCoinStake; |
| 2357 | coins->nHeight = undo.nHeight; |
| 2358 | coins->nVersion = undo.nVersion; |
| 2359 | } else { |
| 2360 | if (coins->IsPruned()) { |
| 2361 | LogPrintf("%s: undo data adding output to missing transaction", __func__); |
| 2362 | fClean = false; |
| 2363 | } |
| 2364 | } |
| 2365 | if (coins->IsAvailable(out.n)) { |
| 2366 | LogPrintf("%s: undo data overwriting existing output", __func__); |
| 2367 | fClean = false; |
| 2368 | } |
| 2369 | |
| 2370 | if (coins->vout.size() < out.n + 1) |
| 2371 | coins->vout.resize(out.n + 1); |
| 2372 | coins->vout[out.n] = undo.txout; |
| 2373 | |
| 2374 | return fClean ? DISCONNECT_OK : DISCONNECT_UNCLEAN; |
| 2375 | } |
| 2376 | |
| 2377 | bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock); |
| 2378 | bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock); |
no test coverage detected