| 1811 | } |
| 1812 | |
| 1813 | void 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 | |
| 1840 | void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight) |
| 1841 | { |
no test coverage detected