mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
refactor: Return optional of Coin in GetCoin
Leaving the parameter as well for now. Co-authored-by: TheCharlatan <seb.kung@gmail.com>
This commit is contained in:
@@ -146,14 +146,14 @@ class CoinsViewBottom final : public CCoinsView
|
||||
std::map<COutPoint, Coin> m_data;
|
||||
|
||||
public:
|
||||
bool GetCoin(const COutPoint& outpoint, Coin& coin) const final
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint, Coin& coin) const final
|
||||
{
|
||||
auto it = m_data.find(outpoint);
|
||||
if (it == m_data.end()) {
|
||||
return false;
|
||||
return std::nullopt;
|
||||
} else {
|
||||
coin = it->second;
|
||||
return true; // TODO GetCoin shouldn't return spent coins
|
||||
return coin; // TODO GetCoin shouldn't return spent coins
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ FUZZ_TARGET(coinscache_sim)
|
||||
// Compare the bottom coinsview (not a CCoinsViewCache) with sim_cache[0].
|
||||
for (uint32_t outpointidx = 0; outpointidx < NUM_OUTPOINTS; ++outpointidx) {
|
||||
Coin realcoin;
|
||||
bool real = bottom.GetCoin(data.outpoints[outpointidx], realcoin);
|
||||
auto real = bottom.GetCoin(data.outpoints[outpointidx], realcoin);
|
||||
auto sim = lookup(outpointidx, 0);
|
||||
if (!sim.has_value()) {
|
||||
assert(!real || realcoin.IsSpent());
|
||||
|
||||
Reference in New Issue
Block a user