Skip to content

Commit aa95947

Browse files
Use the override specifier (C++11) where we expect to be overriding the virtual function of a base class
1 parent acb1153 commit aa95947

18 files changed

+68
-68
lines changed

src/httprpc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
4747
HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
4848
{
4949
}
50-
const char* Name()
50+
const char* Name() override
5151
{
5252
return "HTTP";
5353
}
54-
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
54+
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) override
5555
{
5656
return new HTTPRPCTimer(base, func, millis);
5757
}

src/httpserver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class HTTPWorkItem : public HTTPClosure
4646
req(std::move(_req)), path(_path), func(_func)
4747
{
4848
}
49-
void operator()()
49+
void operator()() override
5050
{
5151
func(req.get(), path);
5252
}

src/keystore.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ class CBasicKeyStore : public CKeyStore
6060
WatchOnlySet setWatchOnly;
6161

6262
public:
63-
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
64-
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
65-
bool HaveKey(const CKeyID &address) const
63+
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
64+
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
65+
bool HaveKey(const CKeyID &address) const override
6666
{
6767
bool result;
6868
{
@@ -71,7 +71,7 @@ class CBasicKeyStore : public CKeyStore
7171
}
7272
return result;
7373
}
74-
void GetKeys(std::set<CKeyID> &setAddress) const
74+
void GetKeys(std::set<CKeyID> &setAddress) const override
7575
{
7676
setAddress.clear();
7777
{
@@ -84,7 +84,7 @@ class CBasicKeyStore : public CKeyStore
8484
}
8585
}
8686
}
87-
bool GetKey(const CKeyID &address, CKey &keyOut) const
87+
bool GetKey(const CKeyID &address, CKey &keyOut) const override
8888
{
8989
{
9090
LOCK(cs_KeyStore);
@@ -97,14 +97,14 @@ class CBasicKeyStore : public CKeyStore
9797
}
9898
return false;
9999
}
100-
virtual bool AddCScript(const CScript& redeemScript);
101-
virtual bool HaveCScript(const CScriptID &hash) const;
102-
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const;
100+
virtual bool AddCScript(const CScript& redeemScript) override;
101+
virtual bool HaveCScript(const CScriptID &hash) const override;
102+
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override;
103103

104-
virtual bool AddWatchOnly(const CScript &dest);
105-
virtual bool RemoveWatchOnly(const CScript &dest);
106-
virtual bool HaveWatchOnly(const CScript &dest) const;
107-
virtual bool HaveWatchOnly() const;
104+
virtual bool AddWatchOnly(const CScript &dest) override;
105+
virtual bool RemoveWatchOnly(const CScript &dest) override;
106+
virtual bool HaveWatchOnly(const CScript &dest) const override;
107+
virtual bool HaveWatchOnly() const override;
108108
};
109109

110110
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;

src/script/interpreter.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ class TransactionSignatureChecker : public BaseSignatureChecker
160160
public:
161161
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(NULL) {}
162162
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {}
163-
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const;
164-
bool CheckLockTime(const CScriptNum& nLockTime) const;
165-
bool CheckSequence(const CScriptNum& nSequence) const;
163+
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override;
164+
bool CheckLockTime(const CScriptNum& nLockTime) const override;
165+
bool CheckSequence(const CScriptNum& nSequence) const override;
166166
};
167167

168168
class MutableTransactionSignatureChecker : public TransactionSignatureChecker

src/script/sigcache.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CachingTransactionSignatureChecker : public TransactionSignatureChecker
4848
public:
4949
CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn), store(storeIn) {}
5050

51-
bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const;
51+
bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const override;
5252
};
5353

5454
void InitSignatureCache();

src/script/sign.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class DummySignatureChecker : public BaseSignatureChecker
393393
public:
394394
DummySignatureChecker() {}
395395

396-
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const
396+
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override
397397
{
398398
return true;
399399
}

src/script/sign.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class TransactionSignatureCreator : public BaseSignatureCreator {
4040

4141
public:
4242
TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn=SIGHASH_ALL);
43-
const BaseSignatureChecker& Checker() const { return checker; }
44-
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const;
43+
const BaseSignatureChecker& Checker() const override { return checker; }
44+
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
4545
};
4646

4747
class MutableTransactionSignatureCreator : public TransactionSignatureCreator {
@@ -55,8 +55,8 @@ class MutableTransactionSignatureCreator : public TransactionSignatureCreator {
5555
class DummySignatureCreator : public BaseSignatureCreator {
5656
public:
5757
DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
58-
const BaseSignatureChecker& Checker() const;
59-
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const;
58+
const BaseSignatureChecker& Checker() const override;
59+
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
6060
};
6161

6262
struct SignatureData {

src/support/lockedpool.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ class Win32LockedPageAllocator: public LockedPageAllocator
148148
{
149149
public:
150150
Win32LockedPageAllocator();
151-
void* AllocateLocked(size_t len, bool *lockingSuccess);
152-
void FreeLocked(void* addr, size_t len);
153-
size_t GetLimit();
151+
void* AllocateLocked(size_t len, bool *lockingSuccess) override;
152+
void FreeLocked(void* addr, size_t len) override;
153+
size_t GetLimit() override;
154154
private:
155155
size_t page_size;
156156
};
@@ -200,9 +200,9 @@ class PosixLockedPageAllocator: public LockedPageAllocator
200200
{
201201
public:
202202
PosixLockedPageAllocator();
203-
void* AllocateLocked(size_t len, bool *lockingSuccess);
204-
void FreeLocked(void* addr, size_t len);
205-
size_t GetLimit();
203+
void* AllocateLocked(size_t len, bool *lockingSuccess) override;
204+
void FreeLocked(void* addr, size_t len) override;
205+
size_t GetLimit() override;
206206
private:
207207
size_t page_size;
208208
};

src/test/addrman_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CAddrManTest : public CAddrMan
2727
insecure_rand = FastRandomContext(true);
2828
}
2929

30-
int RandomInt(int nMax)
30+
int RandomInt(int nMax) override
3131
{
3232
state = (CHashWriter(SER_GETHASH, 0) << state).GetHash().GetCheapHash();
3333
return (unsigned int)(state % nMax);

src/test/allocator_tests.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class TestLockedPageAllocator: public LockedPageAllocator
131131
{
132132
public:
133133
TestLockedPageAllocator(int count_in, int lockedcount_in): count(count_in), lockedcount(lockedcount_in) {}
134-
void* AllocateLocked(size_t len, bool *lockingSuccess)
134+
void* AllocateLocked(size_t len, bool *lockingSuccess) override
135135
{
136136
*lockingSuccess = false;
137137
if (count > 0) {
@@ -146,10 +146,10 @@ class TestLockedPageAllocator: public LockedPageAllocator
146146
}
147147
return 0;
148148
}
149-
void FreeLocked(void* addr, size_t len)
149+
void FreeLocked(void* addr, size_t len) override
150150
{
151151
}
152-
size_t GetLimit()
152+
size_t GetLimit() override
153153
{
154154
return std::numeric_limits<size_t>::max();
155155
}

src/test/net_tests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CAddrManSerializationMock : public CAddrMan
2929
class CAddrManUncorrupted : public CAddrManSerializationMock
3030
{
3131
public:
32-
void Serialize(CDataStream& s) const
32+
void Serialize(CDataStream& s) const override
3333
{
3434
CAddrMan::Serialize(s);
3535
}
@@ -38,7 +38,7 @@ class CAddrManUncorrupted : public CAddrManSerializationMock
3838
class CAddrManCorrupted : public CAddrManSerializationMock
3939
{
4040
public:
41-
void Serialize(CDataStream& s) const
41+
void Serialize(CDataStream& s) const override
4242
{
4343
// Produces corrupt output that claims addrman has 20 addrs when it only has one addr.
4444
unsigned char nVersion = 1;

src/test/versionbits_tests.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class TestConditionChecker : public AbstractThresholdConditionChecker
2222
mutable ThresholdConditionCache cache;
2323

2424
public:
25-
int64_t BeginTime(const Consensus::Params& params) const { return TestTime(10000); }
26-
int64_t EndTime(const Consensus::Params& params) const { return TestTime(20000); }
27-
int Period(const Consensus::Params& params) const { return 1000; }
28-
int Threshold(const Consensus::Params& params) const { return 900; }
29-
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const { return (pindex->nVersion & 0x100); }
25+
int64_t BeginTime(const Consensus::Params& params) const override { return TestTime(10000); }
26+
int64_t EndTime(const Consensus::Params& params) const override { return TestTime(20000); }
27+
int Period(const Consensus::Params& params) const override { return 1000; }
28+
int Threshold(const Consensus::Params& params) const override { return 900; }
29+
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override { return (pindex->nVersion & 0x100); }
3030

3131
ThresholdState GetStateFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateFor(pindexPrev, paramsDummy, cache); }
3232
int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, paramsDummy, cache); }

src/txdb.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ class CCoinsViewDBCursor: public CCoinsViewCursor
8888
public:
8989
~CCoinsViewDBCursor() {}
9090

91-
bool GetKey(COutPoint &key) const;
92-
bool GetValue(Coin &coin) const;
93-
unsigned int GetValueSize() const;
91+
bool GetKey(COutPoint &key) const override;
92+
bool GetValue(Coin &coin) const override;
93+
unsigned int GetValueSize() const override;
9494

95-
bool Valid() const;
96-
void Next();
95+
bool Valid() const override;
96+
void Next() override;
9797

9898
private:
9999
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256 &hashBlockIn):

src/validation.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1462,12 +1462,12 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
14621462
public:
14631463
WarningBitsConditionChecker(int bitIn) : bit(bitIn) {}
14641464

1465-
int64_t BeginTime(const Consensus::Params& params) const { return 0; }
1466-
int64_t EndTime(const Consensus::Params& params) const { return std::numeric_limits<int64_t>::max(); }
1467-
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; }
1468-
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; }
1465+
int64_t BeginTime(const Consensus::Params& params) const override { return 0; }
1466+
int64_t EndTime(const Consensus::Params& params) const override { return std::numeric_limits<int64_t>::max(); }
1467+
int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; }
1468+
int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; }
14691469

1470-
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const
1470+
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override
14711471
{
14721472
return ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) &&
14731473
((pindex->nVersion >> bit) & 1) != 0 &&

src/versionbits.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ class VersionBitsConditionChecker : public AbstractThresholdConditionChecker {
174174
const Consensus::DeploymentPos id;
175175

176176
protected:
177-
int64_t BeginTime(const Consensus::Params& params) const { return params.vDeployments[id].nStartTime; }
178-
int64_t EndTime(const Consensus::Params& params) const { return params.vDeployments[id].nTimeout; }
179-
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; }
180-
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; }
177+
int64_t BeginTime(const Consensus::Params& params) const override { return params.vDeployments[id].nStartTime; }
178+
int64_t EndTime(const Consensus::Params& params) const override { return params.vDeployments[id].nTimeout; }
179+
int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; }
180+
int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; }
181181

182-
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const
182+
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override
183183
{
184184
return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask(params)) != 0);
185185
}

src/wallet/crypter.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ class CCryptoKeyStore : public CBasicKeyStore
157157
bool Lock();
158158

159159
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
160-
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
161-
bool HaveKey(const CKeyID &address) const
160+
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
161+
bool HaveKey(const CKeyID &address) const override
162162
{
163163
{
164164
LOCK(cs_KeyStore);
@@ -168,9 +168,9 @@ class CCryptoKeyStore : public CBasicKeyStore
168168
}
169169
return false;
170170
}
171-
bool GetKey(const CKeyID &address, CKey& keyOut) const;
172-
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
173-
void GetKeys(std::set<CKeyID> &setAddress) const
171+
bool GetKey(const CKeyID &address, CKey& keyOut) const override;
172+
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
173+
void GetKeys(std::set<CKeyID> &setAddress) const override
174174
{
175175
if (!IsCrypted())
176176
{

src/wallet/wallet.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ class CReserveKey : public CReserveScript
11531153
void ReturnKey();
11541154
bool GetReservedKey(CPubKey &pubkey, bool internal = false);
11551155
void KeepKey();
1156-
void KeepScript() { KeepKey(); }
1156+
void KeepScript() override { KeepKey(); }
11571157
};
11581158

11591159

src/zmq/zmqpublishnotifier.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,32 @@ class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier
2424
*/
2525
bool SendMessage(const char *command, const void* data, size_t size);
2626

27-
bool Initialize(void *pcontext);
28-
void Shutdown();
27+
bool Initialize(void *pcontext) override;
28+
void Shutdown() override;
2929
};
3030

3131
class CZMQPublishHashBlockNotifier : public CZMQAbstractPublishNotifier
3232
{
3333
public:
34-
bool NotifyBlock(const CBlockIndex *pindex);
34+
bool NotifyBlock(const CBlockIndex *pindex) override;
3535
};
3636

3737
class CZMQPublishHashTransactionNotifier : public CZMQAbstractPublishNotifier
3838
{
3939
public:
40-
bool NotifyTransaction(const CTransaction &transaction);
40+
bool NotifyTransaction(const CTransaction &transaction) override;
4141
};
4242

4343
class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier
4444
{
4545
public:
46-
bool NotifyBlock(const CBlockIndex *pindex);
46+
bool NotifyBlock(const CBlockIndex *pindex) override;
4747
};
4848

4949
class CZMQPublishRawTransactionNotifier : public CZMQAbstractPublishNotifier
5050
{
5151
public:
52-
bool NotifyTransaction(const CTransaction &transaction);
52+
bool NotifyTransaction(const CTransaction &transaction) override;
5353
};
5454

5555
#endif // BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H

0 commit comments

Comments
 (0)