MCPcopy Create free account
hub / github.com/LUX-Core/lux / ApplyTxInUndo

Function ApplyTxInUndo

src/main.cpp:2345–2375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2343};
2344
2345static 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
2377bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock);
2378bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock);

Callers 1

DisconnectBlockFunction · 0.85

Calls 6

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

Tested by

no test coverage detected