MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AddCoin

Method AddCoin

src/coins.cpp:66–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possible_overwrite) {
67 assert(!coin.IsSpent());
68 if (coin.out.scriptPubKey.IsUnspendable()) return;
69 CCoinsMap::iterator it;
70 bool inserted;
71 std::tie(it, inserted) = cacheCoins.emplace(std::piecewise_construct, std::forward_as_tuple(outpoint), std::tuple<>());
72 bool fresh = false;
73 if (!inserted) {
74 cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
75 }
76 if (!possible_overwrite) {
77 if (!it->second.coin.IsSpent()) {
78 throw std::logic_error("Adding new coin that replaces non-pruned entry");
79 }
80 fresh = !(it->second.flags & CCoinsCacheEntry::DIRTY);
81 }
82 it->second.coin = std::move(coin);
83 it->second.flags |= CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0);
84 cachedCoinsUsage += it->second.coin.DynamicMemoryUsage();
85}
86
87void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool check) {
88 bool fCoinbase = tx.IsCoinBase();

Callers 6

MutateTxSignFunction · 0.80
AddCoinsFunction · 0.80
ApplyTxInUndoFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
CheckAddCoinBaseFunction · 0.80
SignTransactionFunction · 0.80

Calls 3

IsUnspendableMethod · 0.80
IsSpentMethod · 0.45
DynamicMemoryUsageMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
CheckAddCoinBaseFunction · 0.64