Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,240 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, | void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, | ||||
CTxUndo &txundo, int nHeight) { | CTxUndo &txundo, int nHeight) { | ||||
// Mark inputs spent. | // Mark inputs spent. | ||||
if (!tx.IsCoinBase()) { | if (!tx.IsCoinBase()) { | ||||
txundo.vprevout.reserve(tx.vin.size()); | txundo.vprevout.reserve(tx.vin.size()); | ||||
for (const CTxIn &txin : tx.vin) { | for (const CTxIn &txin : tx.vin) { | ||||
CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash); | txundo.vprevout.emplace_back(); | ||||
unsigned nPos = txin.prevout.n; | bool is_spent = | ||||
inputs.SpendCoin(txin.prevout, &txundo.vprevout.back()); | |||||
if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull()) { | assert(is_spent); | ||||
assert(false); | |||||
} | |||||
// Mark an outpoint spent, and construct undo information. | |||||
txundo.vprevout.emplace_back(coins->vout[nPos], coins->nHeight, | |||||
coins->fCoinBase); | |||||
bool ret = coins->Spend(nPos); | |||||
assert(ret); | |||||
} | } | ||||
} | } | ||||
// Add outputs. | // Add outputs. | ||||
inputs.ModifyNewCoins(tx.GetId(), tx.IsCoinBase())->FromTx(tx, nHeight); | AddCoins(inputs, tx, nHeight); | ||||
} | } | ||||
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight) { | void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight) { | ||||
CTxUndo txundo; | CTxUndo txundo; | ||||
UpdateCoins(tx, inputs, txundo, nHeight); | UpdateCoins(tx, inputs, txundo, nHeight); | ||||
} | } | ||||
bool CScriptCheck::operator()() { | bool CScriptCheck::operator()() { | ||||
▲ Show 20 Lines • Show All 3,683 Lines • Show Last 20 Lines |