MCPcopy Create free account
hub / github.com/LUX-Core/lux / ModifyCoins

Method ModifyCoins

src/coins.cpp:138–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138CCoinsModifier CCoinsViewCache::ModifyCoins(const uint256& txid)
139{
140 assert(!hasModifier);
141 std::pair<CCoinsMap::iterator, bool> ret = cacheCoins.insert(std::make_pair(txid, CCoinsCacheEntry()));
142 size_t cachedCoinUsage = 0;
143 if (ret.second) {
144 if (!base->GetCoins(txid, ret.first->second.coins)) {
145 // The parent view does not have this entry; mark it as fresh.
146 ret.first->second.coins.Clear();
147 // New coins must not already exist.
148 if (!ret.first->second.coins.IsPruned())
149 throw std::logic_error("ModifyCoins should not find pre-existing coins on a non-coinbase unless they are pruned!");
150
151 if (!(ret.first->second.flags & CCoinsCacheEntry::FRESH)) {
152 // If the coin is known to be pruned (have no unspent outputs) in
153 // the current view and the cache entry is not dirty, we know the
154 // coin also must be pruned in the parent view as well, so it is safe
155 // to mark this fresh.
156 ret.first->second.flags |= CCoinsCacheEntry::FRESH;
157 }
158 }
159 } else {
160 cachedCoinUsage = ret.first->second.coins.DynamicMemoryUsage();
161 }
162 // Assume that whenever ModifyCoins is called, the entry will be modified.
163 ret.first->second.flags |= CCoinsCacheEntry::DIRTY;
164 return CCoinsModifier(*this, ret.first, cachedCoinUsage);
165}
166
167CCoinsModifier CCoinsViewCache::ModifyNewCoins(const uint256 &txid, bool coinbase) {
168 assert(!hasModifier);

Callers 9

MutateTxSignFunction · 0.80
signrawtransactionFunction · 0.80
UpdateCoinsFunction · 0.80
ApplyTxInUndoFunction · 0.80
DisconnectBlockFunction · 0.80
BuildTxsFunction · 0.80
SetupDummyInputsFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 7

CCoinsCacheEntryClass · 0.85
CCoinsModifierClass · 0.85
IsPrunedMethod · 0.80
insertMethod · 0.45
GetCoinsMethod · 0.45
ClearMethod · 0.45
DynamicMemoryUsageMethod · 0.45

Tested by 4

BuildTxsFunction · 0.64
SetupDummyInputsFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64