MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / ApplyTxInUndo

Function ApplyTxInUndo

src/main.cpp:2039–2063  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

2037 * @return True on success.
2038 */
2039static 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
2065bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean)
2066{

Callers 1

DisconnectBlockFunction · 0.85

Calls 7

errorFunction · 0.85
ModifyCoinsMethod · 0.80
IsPrunedMethod · 0.80
IsAvailableMethod · 0.80
resizeMethod · 0.80
ClearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected