| 70 | } |
| 71 | |
| 72 | CCoinsMap::const_iterator CCoinsViewCache::FetchCoins(const uint256 &txid) const { |
| 73 | CCoinsMap::iterator it = cacheCoins.find(txid); |
| 74 | if (it != cacheCoins.end()) |
| 75 | return it; |
| 76 | CCoins tmp; |
| 77 | if (!base->GetCoins(txid, tmp)) |
| 78 | return cacheCoins.end(); |
| 79 | CCoinsMap::iterator ret = cacheCoins.insert(std::make_pair(txid, CCoinsCacheEntry())).first; |
| 80 | tmp.swap(ret->second.coins); |
| 81 | if (ret->second.coins.IsPruned()) { |
| 82 | // The parent only has an empty entry for this txid; we can consider our |
| 83 | // version as fresh. |
| 84 | ret->second.flags = CCoinsCacheEntry::FRESH; |
| 85 | } |
| 86 | cachedCoinsUsage += ret->second.coins.DynamicMemoryUsage(); |
| 87 | return ret; |
| 88 | } |
| 89 | |
| 90 | bool CCoinsViewCache::GetCoins(const uint256 &txid, CCoins &coins) const { |
| 91 | CCoinsMap::const_iterator it = FetchCoins(txid); |
nothing calls this directly
no test coverage detected