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

Function UpdateCoins

src/main.cpp:1813–1838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1811}
1812
1813void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
1814{
1815 // mark inputs spent
1816 if (!tx.IsCoinBase()) {
1817 txundo.vprevout.reserve(tx.vin.size());
1818 BOOST_FOREACH(const CTxIn &txin, tx.vin) {
1819 CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash);
1820 unsigned nPos = txin.prevout.n;
1821
1822 if (nPos >= coins->vout.size() || coins->vout[nPos].IsNull())
1823 assert(false);
1824 // mark an outpoint spent, and construct undo information
1825 txundo.vprevout.push_back(CTxInUndo(coins->vout[nPos]));
1826 coins->Spend(nPos);
1827 if (coins->vout.size() == 0) {
1828 CTxInUndo& undo = txundo.vprevout.back();
1829 undo.nHeight = coins->nHeight;
1830 undo.fCoinBase = coins->fCoinBase;
1831 undo.nVersion = coins->nVersion;
1832 }
1833 }
1834 }
1835
1836 // add outputs
1837 inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight);
1838}
1839
1840void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight)
1841{

Callers 2

checkMethod · 0.85
ConnectBlockFunction · 0.85

Calls 6

reserveMethod · 0.80
ModifyCoinsMethod · 0.80
IsCoinBaseMethod · 0.45
sizeMethod · 0.45
FromTxMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected