mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-15 10:07:41 +02:00
refactor: normalize CCoinsView whitespace and signatures
Let's get these out of the way to simplify riskier followup commits
This commit is contained in:
@@ -25,18 +25,18 @@ void CCoinsView::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_h
|
||||
|
||||
std::unique_ptr<CCoinsViewCursor> CCoinsView::Cursor() const { return nullptr; }
|
||||
|
||||
bool CCoinsView::HaveCoin(const COutPoint &outpoint) const
|
||||
bool CCoinsView::HaveCoin(const COutPoint& outpoint) const
|
||||
{
|
||||
return GetCoin(outpoint).has_value();
|
||||
}
|
||||
|
||||
CCoinsViewBacked::CCoinsViewBacked(CCoinsView *in_view) : base(in_view) { }
|
||||
CCoinsViewBacked::CCoinsViewBacked(CCoinsView* in_view) : base(in_view) { }
|
||||
std::optional<Coin> CCoinsViewBacked::GetCoin(const COutPoint& outpoint) const { return base->GetCoin(outpoint); }
|
||||
std::optional<Coin> CCoinsViewBacked::PeekCoin(const COutPoint& outpoint) const { return base->PeekCoin(outpoint); }
|
||||
bool CCoinsViewBacked::HaveCoin(const COutPoint &outpoint) const { return base->HaveCoin(outpoint); }
|
||||
bool CCoinsViewBacked::HaveCoin(const COutPoint& outpoint) const { return base->HaveCoin(outpoint); }
|
||||
uint256 CCoinsViewBacked::GetBestBlock() const { return base->GetBestBlock(); }
|
||||
std::vector<uint256> CCoinsViewBacked::GetHeadBlocks() const { return base->GetHeadBlocks(); }
|
||||
void CCoinsViewBacked::SetBackend(CCoinsView &in_view) { base = &in_view; }
|
||||
void CCoinsViewBacked::SetBackend(CCoinsView& in_view) { base = &in_view; }
|
||||
void CCoinsViewBacked::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) { base->BatchWrite(cursor, block_hash); }
|
||||
std::unique_ptr<CCoinsViewCursor> CCoinsViewBacked::Cursor() const { return base->Cursor(); }
|
||||
size_t CCoinsViewBacked::EstimateSize() const { return base->EstimateSize(); }
|
||||
@@ -185,7 +185,8 @@ 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());
|
||||
}
|
||||
@@ -201,7 +202,8 @@ uint256 CCoinsViewCache::GetBestBlock() const {
|
||||
return m_block_hash;
|
||||
}
|
||||
|
||||
void CCoinsViewCache::SetBestBlock(const uint256 &in_block_hash) {
|
||||
void CCoinsViewCache::SetBestBlock(const uint256& in_block_hash)
|
||||
{
|
||||
m_block_hash = in_block_hash;
|
||||
}
|
||||
|
||||
|
||||
22
src/coins.h
22
src/coins.h
@@ -229,7 +229,7 @@ using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType;
|
||||
class CCoinsViewCursor
|
||||
{
|
||||
public:
|
||||
CCoinsViewCursor(const uint256 &in_block_hash): block_hash(in_block_hash) {}
|
||||
CCoinsViewCursor(const uint256& in_block_hash) : block_hash(in_block_hash) {}
|
||||
virtual ~CCoinsViewCursor() = default;
|
||||
|
||||
virtual bool GetKey(COutPoint &key) const = 0;
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
virtual void Next() = 0;
|
||||
|
||||
//! Get best block at the time this cursor was created
|
||||
const uint256 &GetBestBlock() const { return block_hash; }
|
||||
const uint256& GetBestBlock() const { return block_hash; }
|
||||
private:
|
||||
uint256 block_hash;
|
||||
};
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
|
||||
//! Just check whether a given outpoint is unspent.
|
||||
//! May populate the cache. Use PeekCoin() to perform a non-caching lookup.
|
||||
virtual bool HaveCoin(const COutPoint &outpoint) const;
|
||||
virtual bool HaveCoin(const COutPoint& outpoint) const;
|
||||
|
||||
//! Retrieve the block hash whose state this CCoinsView currently represents
|
||||
virtual uint256 GetBestBlock() const;
|
||||
@@ -347,16 +347,16 @@ public:
|
||||
class CCoinsViewBacked : public CCoinsView
|
||||
{
|
||||
protected:
|
||||
CCoinsView *base;
|
||||
CCoinsView* base;
|
||||
|
||||
public:
|
||||
CCoinsViewBacked(CCoinsView *in_view);
|
||||
CCoinsViewBacked(CCoinsView* in_view);
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override;
|
||||
std::optional<Coin> PeekCoin(const COutPoint& outpoint) const override;
|
||||
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||
bool HaveCoin(const COutPoint& outpoint) const override;
|
||||
uint256 GetBestBlock() const override;
|
||||
std::vector<uint256> GetHeadBlocks() const override;
|
||||
void SetBackend(CCoinsView &in_view);
|
||||
void SetBackend(CCoinsView& in_view);
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override;
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const override;
|
||||
size_t EstimateSize() const override;
|
||||
@@ -395,7 +395,7 @@ protected:
|
||||
virtual std::optional<Coin> FetchCoinFromBase(const COutPoint& outpoint) const;
|
||||
|
||||
public:
|
||||
CCoinsViewCache(CCoinsView *in_base, bool deterministic = false);
|
||||
CCoinsViewCache(CCoinsView* in_base, bool deterministic = false);
|
||||
|
||||
/**
|
||||
* By deleting the copy constructor, we prevent accidentally using it when one intends to create a cache on top of a base cache.
|
||||
@@ -405,9 +405,9 @@ public:
|
||||
// Standard CCoinsView methods
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override;
|
||||
std::optional<Coin> PeekCoin(const COutPoint& outpoint) const override;
|
||||
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||
bool HaveCoin(const COutPoint& outpoint) const override;
|
||||
uint256 GetBestBlock() const override;
|
||||
void SetBestBlock(const uint256 &block_hash);
|
||||
void SetBestBlock(const uint256& block_hash);
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override;
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const override {
|
||||
throw std::logic_error("CCoinsViewCache cursor iteration not supported.");
|
||||
@@ -578,7 +578,7 @@ public:
|
||||
}
|
||||
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override;
|
||||
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||
bool HaveCoin(const COutPoint& outpoint) const override;
|
||||
std::optional<Coin> PeekCoin(const COutPoint& outpoint) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -78,7 +78,8 @@ std::optional<Coin> CCoinsViewDB::GetCoin(const COutPoint& outpoint) const
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool CCoinsViewDB::HaveCoin(const COutPoint &outpoint) const {
|
||||
bool CCoinsViewDB::HaveCoin(const COutPoint& outpoint) const
|
||||
{
|
||||
return m_db->Exists(CoinEntry(&outpoint));
|
||||
}
|
||||
|
||||
@@ -174,7 +175,7 @@ class CCoinsViewDBCursor: public CCoinsViewCursor
|
||||
public:
|
||||
// Prefer using CCoinsViewDB::Cursor() since we want to perform some
|
||||
// cache warmup on instantiation.
|
||||
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256&in_block_hash):
|
||||
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256& in_block_hash):
|
||||
CCoinsViewCursor(in_block_hash), pcursor(pcursorIn) {}
|
||||
~CCoinsViewDBCursor() = default;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
explicit CCoinsViewDB(DBParams db_params, CoinsViewOptions options);
|
||||
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override;
|
||||
bool HaveCoin(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& block_hash) override;
|
||||
|
||||
Reference in New Issue
Block a user