Undo files contain data needed to disconnect a block from the blockchain. It basically contains instances of CBlockUndo
:
/** Undo information for a CBlock */
class CBlockUndo
{
public:
std::vector<CTxUndo> vtxundo; // for all but the coinbase
SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); }
};
/** Undo information for a CTransaction */
class CTxUndo
{
public:
// undo information for all txins
std::vector<Coin> vprevout;
SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); }
};
From my understanding, it's only a wrapper over the spent coins and it has no extra information regarding to the actual block. On the other hand, as far as I can see, undoing a block needs undoing all transactions the block contains. And to undo a transaction we need to perform two thing:
- Removing the transaction outputs from the UTXO set
- Restoring the inputs as UTXO (restoring the UTXOs that are spent in the transaction)
If I'm correct, I can't understand the need behind having undo files.