MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / SpendCoin

Method SpendCoin

src/coins.cpp:174–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin *moveout) {
175 CCoinsMap::iterator it = FetchCoin(outpoint);
176 if (it == cacheCoins.end()) {
177 return false;
178 }
179 Assume(TrySub(m_dirty_count, it->second.IsDirty()));
180 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
181 TRACE5(utxocache, spent, outpoint.GetTxId().data(), outpoint.GetN(),
182 it->second.coin.GetHeight(),
183 it->second.coin.GetTxOut().nValue.ToString().c_str(),
184 it->second.coin.IsCoinBase());
185 if (moveout) {
186 *moveout = std::move(it->second.coin);
187 }
188 if (it->second.IsFresh()) {
189 cacheCoins.erase(it);
190 } else {
191 CCoinsCacheEntry::SetDirty(*it, m_sentinel);
192 ++m_dirty_count;
193 it->second.coin.Clear();
194 }
195 return true;
196}
197
198static const Coin coinEmpty;
199

Callers 13

checkMethod · 0.80
SpendCoinsFunction · 0.80
ApplyBlockUndoFunction · 0.80
RollforwardBlockMethod · 0.80
SimulationTestMethod · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80
CheckSpendCoinFunction · 0.80
TestFlushBehaviorMethod · 0.80
TestCoinsViewFunction · 0.80
FUZZ_TARGETFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80

Calls 12

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

Tested by 9

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