MCPcopy Create free account
hub / github.com/ElementsProject/elements / SpendCoin

Method SpendCoin

src/coins.cpp:139–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
140 CCoinsMap::iterator it = FetchCoin(outpoint);
141 if (it == cacheCoins.end()) return false;
142 cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
143 TRACE5(utxocache, spent,
144 outpoint.hash.data(),
145 (uint32_t)outpoint.n,
146 (uint32_t)it->second.coin.nHeight,
147 it->second.coin.out.nValue.IsExplicit() ? (int64_t)it->second.coin.out.nValue.GetAmount() : 0,
148 (bool)it->second.coin.IsCoinBase());
149 if (moveout) {
150 *moveout = std::move(it->second.coin);
151 }
152 if (it->second.flags & CCoinsCacheEntry::FRESH) {
153 cacheCoins.erase(it);
154 } else {
155 it->second.flags |= CCoinsCacheEntry::DIRTY;
156 it->second.coin.Clear();
157 }
158 return true;
159}
160
161// ELEMENTS:
162// Because g_con_elementsmode is only set after the moment coinEmpty is initialized,

Callers 8

checkMethod · 0.80
UpdateCoinsFunction · 0.80
DisconnectBlockMethod · 0.80
RollforwardBlockMethod · 0.80
SimulationTestFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
CheckSpendCoinsFunction · 0.80
FUZZ_TARGET_INITFunction · 0.80

Calls 8

IsExplicitMethod · 0.80
GetAmountMethod · 0.80
endMethod · 0.45
DynamicMemoryUsageMethod · 0.45
dataMethod · 0.45
IsCoinBaseMethod · 0.45
eraseMethod · 0.45
ClearMethod · 0.45

Tested by 4

SimulationTestFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
CheckSpendCoinsFunction · 0.64
FUZZ_TARGET_INITFunction · 0.64