* Apply the undo operation of a CTxInUndo to the given chain state. * @param undo The undo object. * @param view The coins view to which to apply the changes. * @param out The out point that corresponds to the tx input. * @return True on success. */
| 2037 | * @return True on success. |
| 2038 | */ |
| 2039 | static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint& out) |
| 2040 | { |
| 2041 | bool fClean = true; |
| 2042 | |
| 2043 | CCoinsModifier coins = view.ModifyCoins(out.hash); |
| 2044 | if (undo.nHeight != 0) { |
| 2045 | // undo data contains height: this is the last output of the prevout tx being spent |
| 2046 | if (!coins->IsPruned()) |
| 2047 | fClean = fClean && error("%s: undo data overwriting existing transaction", __func__); |
| 2048 | coins->Clear(); |
| 2049 | coins->fCoinBase = undo.fCoinBase; |
| 2050 | coins->nHeight = undo.nHeight; |
| 2051 | coins->nVersion = undo.nVersion; |
| 2052 | } else { |
| 2053 | if (coins->IsPruned()) |
| 2054 | fClean = fClean && error("%s: undo data adding output to missing transaction", __func__); |
| 2055 | } |
| 2056 | if (coins->IsAvailable(out.n)) |
| 2057 | fClean = fClean && error("%s: undo data overwriting existing output", __func__); |
| 2058 | if (coins->vout.size() < out.n+1) |
| 2059 | coins->vout.resize(out.n+1); |
| 2060 | coins->vout[out.n] = undo.txout; |
| 2061 | |
| 2062 | return fClean; |
| 2063 | } |
| 2064 | |
| 2065 | bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean) |
| 2066 | { |
no test coverage detected