Skip to content

Commit 40e6da5

Browse files
committed
Use override keyword.
In CCoinsViewMemPool, mark the overriding methods actually as override. This ensures that the compiler will enforce and catch any potential changes to the superclass method signature.
1 parent 7ecb256 commit 40e6da5

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

divi/src/coins.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,12 @@ class CCoinsViewBacked : public CCoinsView
311311

312312
public:
313313
CCoinsViewBacked(CCoinsView* viewIn);
314-
bool GetCoins(const uint256& txid, CCoins& coins) const;
315-
bool HaveCoins(const uint256& txid) const;
316-
uint256 GetBestBlock() const;
314+
bool GetCoins(const uint256& txid, CCoins& coins) const override;
315+
bool HaveCoins(const uint256& txid) const override;
316+
uint256 GetBestBlock() const override;
317317
void SetBackend(CCoinsView& viewIn);
318-
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock);
319-
bool GetStats(CCoinsStats& stats) const;
318+
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) override;
319+
bool GetStats(CCoinsStats& stats) const override;
320320
};
321321

322322
class CCoinsViewCache;
@@ -372,11 +372,11 @@ class CCoinsViewCache : public CCoinsViewBacked
372372
~CCoinsViewCache();
373373

374374
// Standard CCoinsView methods
375-
bool GetCoins(const uint256& txid, CCoins& coins) const;
376-
bool HaveCoins(const uint256& txid) const;
377-
uint256 GetBestBlock() const;
375+
bool GetCoins(const uint256& txid, CCoins& coins) const override;
376+
bool HaveCoins(const uint256& txid) const override;
377+
uint256 GetBestBlock() const override;
378378
void SetBestBlock(const uint256& hashBlock);
379-
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock);
379+
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) override;
380380

381381
/**
382382
* Return a pointer to CCoins in the cache, or NULL if not found. This is

divi/src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class CCoinsViewErrorCatcher : public CCoinsViewBacked
168168
{
169169
public:
170170
CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {}
171-
bool GetCoins(const uint256& txid, CCoins& coins) const
171+
bool GetCoins(const uint256& txid, CCoins& coins) const override
172172
{
173173
try {
174174
return CCoinsViewBacked::GetCoins(txid, coins);

divi/src/test/coins_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CCoinsViewTest : public CCoinsView
2222
std::map<uint256, CCoins> map_;
2323

2424
public:
25-
bool GetCoins(const uint256& txid, CCoins& coins) const
25+
bool GetCoins(const uint256& txid, CCoins& coins) const override
2626
{
2727
auto it = map_.find(txid);
2828
if (it == map_.end()) {
@@ -36,15 +36,15 @@ class CCoinsViewTest : public CCoinsView
3636
return true;
3737
}
3838

39-
bool HaveCoins(const uint256& txid) const
39+
bool HaveCoins(const uint256& txid) const override
4040
{
4141
CCoins coins;
4242
return GetCoins(txid, coins);
4343
}
4444

45-
uint256 GetBestBlock() const { return hashBestBlock_; }
45+
uint256 GetBestBlock() const override { return hashBestBlock_; }
4646

47-
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock)
47+
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) override
4848
{
4949
for (auto it = mapCoins.begin(); it != mapCoins.end(); ) {
5050
map_[it->first] = it->second.coins;
@@ -59,7 +59,7 @@ class CCoinsViewTest : public CCoinsView
5959
return true;
6060
}
6161

62-
bool GetStats(CCoinsStats& stats) const { return false; }
62+
bool GetStats(CCoinsStats& stats) const override { return false; }
6363
};
6464
}
6565

divi/src/txdb.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class CCoinsViewDB : public CCoinsView
3939
public:
4040
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
4141

42-
bool GetCoins(const uint256& txid, CCoins& coins) const;
43-
bool HaveCoins(const uint256& txid) const;
44-
uint256 GetBestBlock() const;
45-
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock);
46-
bool GetStats(CCoinsStats& stats) const;
42+
bool GetCoins(const uint256& txid, CCoins& coins) const override;
43+
bool HaveCoins(const uint256& txid) const override;
44+
uint256 GetBestBlock() const override;
45+
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) override;
46+
bool GetStats(CCoinsStats& stats) const override;
4747
};
4848

4949
/** Access to the block database (blocks/index/) */

divi/src/txmempool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ class CCoinsViewMemPool : public CCoinsViewBacked
222222

223223
public:
224224
CCoinsViewMemPool(CCoinsView* baseIn, CTxMemPool& mempoolIn);
225-
bool GetCoins(const uint256& txid, CCoins& coins) const;
226-
bool HaveCoins(const uint256& txid) const;
225+
bool GetCoins(const uint256& txid, CCoins& coins) const override;
226+
bool HaveCoins(const uint256& txid) const override;
227227
};
228228

229229
#endif // BITCOIN_TXMEMPOOL_H

0 commit comments

Comments
 (0)