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

Method FetchCoin

src/coins.cpp:51–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51CCoinsMap::iterator CCoinsViewCache::FetchCoin(const COutPoint &outpoint) const {
52 CCoinsMap::iterator it = cacheCoins.find(native_key(outpoint));
53 if (it != cacheCoins.end())
54 return it;
55 Coin tmp;
56 if (!base->GetCoin(outpoint, tmp))
57 return cacheCoins.end();
58 CCoinsMap::iterator ret = cacheCoins.emplace(std::piecewise_construct,
59 std::forward_as_tuple(native_key(outpoint)),
60 std::forward_as_tuple(std::move(tmp))).first;
61 if (ret->second.coin.IsSpent()) {
62 // The parent only has an empty entry for this outpoint; we can consider our
63 // version as fresh.
64 ret->second.flags = CCoinsCacheEntry::FRESH;
65 }
66 cachedCoinsUsage += ret->second.coin.DynamicMemoryUsage();
67 return ret;
68}
69
70bool CCoinsViewCache::GetCoin(const COutPoint &outpoint, Coin &coin) const {
71 CCoinsMap::const_iterator it = FetchCoin(outpoint);

Callers

nothing calls this directly

Calls 6

native_keyFunction · 0.85
findMethod · 0.80
endMethod · 0.45
GetCoinMethod · 0.45
IsSpentMethod · 0.45
DynamicMemoryUsageMethod · 0.45

Tested by

no test coverage detected