MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SpendCoin

Method SpendCoin

src/coins.cpp:132–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
133 CCoinsMap::iterator it = FetchCoin(outpoint);
134 if (it == cacheCoins.end()) return false;
135 Assume(TrySub(m_dirty_count, it->second.IsDirty()));
136 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
137 TRACEPOINT(utxocache, spent,
138 outpoint.hash.data(),
139 (uint32_t)outpoint.n,
140 (uint32_t)it->second.coin.nHeight,
141 (int64_t)it->second.coin.out.nValue,
142 (bool)it->second.coin.IsCoinBase());
143 if (moveout) {
144 *moveout = std::move(it->second.coin);
145 }
146 if (it->second.IsFresh()) {
147 cacheCoins.erase(it);
148 } else {
149 CCoinsCacheEntry::SetDirty(*it, m_sentinel);
150 ++m_dirty_count;
151 it->second.coin.Clear();
152 }
153 return true;
154}
155
156static const Coin coinEmpty;
157

Callers 11

checkMethod · 0.80
UpdateCoinsFunction · 0.80
DisconnectBlockMethod · 0.80
RollforwardBlockMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
SimulationTestMethod · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80
CheckSpendCoinsFunction · 0.80
TestFlushBehaviorMethod · 0.80
TestCoinsViewFunction · 0.80
FUZZ_TARGETFunction · 0.80

Calls 9

TrySubFunction · 0.85
endMethod · 0.45
IsDirtyMethod · 0.45
DynamicMemoryUsageMethod · 0.45
dataMethod · 0.45
IsCoinBaseMethod · 0.45
IsFreshMethod · 0.45
eraseMethod · 0.45
ClearMethod · 0.45

Tested by 7

BOOST_AUTO_TEST_CASEFunction · 0.64
SimulationTestMethod · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64
CheckSpendCoinsFunction · 0.64
TestFlushBehaviorMethod · 0.64
TestCoinsViewFunction · 0.64
FUZZ_TARGETFunction · 0.64