mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-02 11:09:36 +01:00
coins: simplify HaveCoin usages
Direct `CCoinsViewDB::HaveCoin` calls aren't called in production anyway, so let's just revert to delegating to `::GetCoin`. Benchmark at this commit: | ns/tx | tx/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 995.62 | 1,004,398.82 | 0.9% | 1.10 | `HaveInputsOnDisk`
This commit is contained in:
@@ -165,12 +165,14 @@ const Coin& CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool CCoinsViewCache::HaveCoin(const COutPoint &outpoint) const {
|
||||
bool CCoinsViewCache::HaveCoin(const COutPoint& outpoint) const
|
||||
{
|
||||
CCoinsMap::const_iterator it = FetchCoin(outpoint);
|
||||
return (it != cacheCoins.end() && !it->second.coin.IsSpent());
|
||||
}
|
||||
|
||||
bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
|
||||
bool CCoinsViewCache::HaveCoinInCache(const COutPoint& outpoint) const
|
||||
{
|
||||
CCoinsMap::const_iterator it = cacheCoins.find(outpoint);
|
||||
return (it != cacheCoins.end() && !it->second.coin.IsSpent());
|
||||
}
|
||||
|
||||
@@ -74,10 +74,6 @@ std::optional<Coin> CCoinsViewDB::GetCoin(const COutPoint& outpoint) const
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool CCoinsViewDB::HaveCoin(const COutPoint &outpoint) const {
|
||||
return m_db->Exists(CoinEntry(&outpoint));
|
||||
}
|
||||
|
||||
uint256 CCoinsViewDB::GetBestBlock() const {
|
||||
uint256 hashBestChain;
|
||||
if (!m_db->Read(DB_BEST_BLOCK, hashBestChain))
|
||||
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
explicit CCoinsViewDB(DBParams db_params, CoinsViewOptions options);
|
||||
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override;
|
||||
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||
uint256 GetBestBlock() const override;
|
||||
std::vector<uint256> GetHeadBlocks() const override;
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& hashBlock) override;
|
||||
|
||||
Reference in New Issue
Block a user