Use the override specifier (C++11) where we expect to be overriding the virtual function of a base class

This commit is contained in:
practicalswift 2017-06-20 21:58:56 +02:00
parent acb11535cb
commit aa95947ded
18 changed files with 68 additions and 68 deletions

View File

@ -47,11 +47,11 @@ public:
HTTPRPCTimerInterface(struct event_base* _base) : base(_base) HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
{ {
} }
const char* Name() const char* Name() override
{ {
return "HTTP"; return "HTTP";
} }
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) override
{ {
return new HTTPRPCTimer(base, func, millis); return new HTTPRPCTimer(base, func, millis);
} }

View File

@ -46,7 +46,7 @@ public:
req(std::move(_req)), path(_path), func(_func) req(std::move(_req)), path(_path), func(_func)
{ {
} }
void operator()() void operator()() override
{ {
func(req.get(), path); func(req.get(), path);
} }

View File

@ -60,9 +60,9 @@ protected:
WatchOnlySet setWatchOnly; WatchOnlySet setWatchOnly;
public: public:
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const; bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
bool HaveKey(const CKeyID &address) const bool HaveKey(const CKeyID &address) const override
{ {
bool result; bool result;
{ {
@ -71,7 +71,7 @@ public:
} }
return result; return result;
} }
void GetKeys(std::set<CKeyID> &setAddress) const void GetKeys(std::set<CKeyID> &setAddress) const override
{ {
setAddress.clear(); setAddress.clear();
{ {
@ -84,7 +84,7 @@ public:
} }
} }
} }
bool GetKey(const CKeyID &address, CKey &keyOut) const bool GetKey(const CKeyID &address, CKey &keyOut) const override
{ {
{ {
LOCK(cs_KeyStore); LOCK(cs_KeyStore);
@ -97,14 +97,14 @@ public:
} }
return false; return false;
} }
virtual bool AddCScript(const CScript& redeemScript); virtual bool AddCScript(const CScript& redeemScript) override;
virtual bool HaveCScript(const CScriptID &hash) const; virtual bool HaveCScript(const CScriptID &hash) const override;
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const; virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override;
virtual bool AddWatchOnly(const CScript &dest); virtual bool AddWatchOnly(const CScript &dest) override;
virtual bool RemoveWatchOnly(const CScript &dest); virtual bool RemoveWatchOnly(const CScript &dest) override;
virtual bool HaveWatchOnly(const CScript &dest) const; virtual bool HaveWatchOnly(const CScript &dest) const override;
virtual bool HaveWatchOnly() const; virtual bool HaveWatchOnly() const override;
}; };
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial; typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;

View File

@ -160,9 +160,9 @@ protected:
public: public:
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(NULL) {} TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(NULL) {}
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {} TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {}
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const; bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override;
bool CheckLockTime(const CScriptNum& nLockTime) const; bool CheckLockTime(const CScriptNum& nLockTime) const override;
bool CheckSequence(const CScriptNum& nSequence) const; bool CheckSequence(const CScriptNum& nSequence) const override;
}; };
class MutableTransactionSignatureChecker : public TransactionSignatureChecker class MutableTransactionSignatureChecker : public TransactionSignatureChecker

View File

@ -48,7 +48,7 @@ private:
public: public:
CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn), store(storeIn) {} CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn), store(storeIn) {}
bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const; bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const override;
}; };
void InitSignatureCache(); void InitSignatureCache();

View File

@ -393,7 +393,7 @@ class DummySignatureChecker : public BaseSignatureChecker
public: public:
DummySignatureChecker() {} DummySignatureChecker() {}
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override
{ {
return true; return true;
} }

View File

@ -40,8 +40,8 @@ class TransactionSignatureCreator : public BaseSignatureCreator {
public: public:
TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn=SIGHASH_ALL); TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn=SIGHASH_ALL);
const BaseSignatureChecker& Checker() const { return checker; } const BaseSignatureChecker& Checker() const override { return checker; }
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const; bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
}; };
class MutableTransactionSignatureCreator : public TransactionSignatureCreator { class MutableTransactionSignatureCreator : public TransactionSignatureCreator {
@ -55,8 +55,8 @@ public:
class DummySignatureCreator : public BaseSignatureCreator { class DummySignatureCreator : public BaseSignatureCreator {
public: public:
DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {} DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
const BaseSignatureChecker& Checker() const; const BaseSignatureChecker& Checker() const override;
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const; bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
}; };
struct SignatureData { struct SignatureData {

View File

@ -148,9 +148,9 @@ class Win32LockedPageAllocator: public LockedPageAllocator
{ {
public: public:
Win32LockedPageAllocator(); Win32LockedPageAllocator();
void* AllocateLocked(size_t len, bool *lockingSuccess); void* AllocateLocked(size_t len, bool *lockingSuccess) override;
void FreeLocked(void* addr, size_t len); void FreeLocked(void* addr, size_t len) override;
size_t GetLimit(); size_t GetLimit() override;
private: private:
size_t page_size; size_t page_size;
}; };
@ -200,9 +200,9 @@ class PosixLockedPageAllocator: public LockedPageAllocator
{ {
public: public:
PosixLockedPageAllocator(); PosixLockedPageAllocator();
void* AllocateLocked(size_t len, bool *lockingSuccess); void* AllocateLocked(size_t len, bool *lockingSuccess) override;
void FreeLocked(void* addr, size_t len); void FreeLocked(void* addr, size_t len) override;
size_t GetLimit(); size_t GetLimit() override;
private: private:
size_t page_size; size_t page_size;
}; };

View File

@ -27,7 +27,7 @@ public:
insecure_rand = FastRandomContext(true); insecure_rand = FastRandomContext(true);
} }
int RandomInt(int nMax) int RandomInt(int nMax) override
{ {
state = (CHashWriter(SER_GETHASH, 0) << state).GetHash().GetCheapHash(); state = (CHashWriter(SER_GETHASH, 0) << state).GetHash().GetCheapHash();
return (unsigned int)(state % nMax); return (unsigned int)(state % nMax);

View File

@ -131,7 +131,7 @@ class TestLockedPageAllocator: public LockedPageAllocator
{ {
public: public:
TestLockedPageAllocator(int count_in, int lockedcount_in): count(count_in), lockedcount(lockedcount_in) {} TestLockedPageAllocator(int count_in, int lockedcount_in): count(count_in), lockedcount(lockedcount_in) {}
void* AllocateLocked(size_t len, bool *lockingSuccess) void* AllocateLocked(size_t len, bool *lockingSuccess) override
{ {
*lockingSuccess = false; *lockingSuccess = false;
if (count > 0) { if (count > 0) {
@ -146,10 +146,10 @@ public:
} }
return 0; return 0;
} }
void FreeLocked(void* addr, size_t len) void FreeLocked(void* addr, size_t len) override
{ {
} }
size_t GetLimit() size_t GetLimit() override
{ {
return std::numeric_limits<size_t>::max(); return std::numeric_limits<size_t>::max();
} }

View File

@ -29,7 +29,7 @@ public:
class CAddrManUncorrupted : public CAddrManSerializationMock class CAddrManUncorrupted : public CAddrManSerializationMock
{ {
public: public:
void Serialize(CDataStream& s) const void Serialize(CDataStream& s) const override
{ {
CAddrMan::Serialize(s); CAddrMan::Serialize(s);
} }
@ -38,7 +38,7 @@ public:
class CAddrManCorrupted : public CAddrManSerializationMock class CAddrManCorrupted : public CAddrManSerializationMock
{ {
public: public:
void Serialize(CDataStream& s) const void Serialize(CDataStream& s) const override
{ {
// Produces corrupt output that claims addrman has 20 addrs when it only has one addr. // Produces corrupt output that claims addrman has 20 addrs when it only has one addr.
unsigned char nVersion = 1; unsigned char nVersion = 1;

View File

@ -22,11 +22,11 @@ private:
mutable ThresholdConditionCache cache; mutable ThresholdConditionCache cache;
public: public:
int64_t BeginTime(const Consensus::Params& params) const { return TestTime(10000); } int64_t BeginTime(const Consensus::Params& params) const override { return TestTime(10000); }
int64_t EndTime(const Consensus::Params& params) const { return TestTime(20000); } int64_t EndTime(const Consensus::Params& params) const override { return TestTime(20000); }
int Period(const Consensus::Params& params) const { return 1000; } int Period(const Consensus::Params& params) const override { return 1000; }
int Threshold(const Consensus::Params& params) const { return 900; } int Threshold(const Consensus::Params& params) const override { return 900; }
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const { return (pindex->nVersion & 0x100); } bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override { return (pindex->nVersion & 0x100); }
ThresholdState GetStateFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateFor(pindexPrev, paramsDummy, cache); } ThresholdState GetStateFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateFor(pindexPrev, paramsDummy, cache); }
int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, paramsDummy, cache); } int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, paramsDummy, cache); }

View File

@ -88,12 +88,12 @@ class CCoinsViewDBCursor: public CCoinsViewCursor
public: public:
~CCoinsViewDBCursor() {} ~CCoinsViewDBCursor() {}
bool GetKey(COutPoint &key) const; bool GetKey(COutPoint &key) const override;
bool GetValue(Coin &coin) const; bool GetValue(Coin &coin) const override;
unsigned int GetValueSize() const; unsigned int GetValueSize() const override;
bool Valid() const; bool Valid() const override;
void Next(); void Next() override;
private: private:
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256 &hashBlockIn): CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256 &hashBlockIn):

View File

@ -1462,12 +1462,12 @@ private:
public: public:
WarningBitsConditionChecker(int bitIn) : bit(bitIn) {} WarningBitsConditionChecker(int bitIn) : bit(bitIn) {}
int64_t BeginTime(const Consensus::Params& params) const { return 0; } int64_t BeginTime(const Consensus::Params& params) const override { return 0; }
int64_t EndTime(const Consensus::Params& params) const { return std::numeric_limits<int64_t>::max(); } int64_t EndTime(const Consensus::Params& params) const override { return std::numeric_limits<int64_t>::max(); }
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; } int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; }
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; } int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; }
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override
{ {
return ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && return ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) &&
((pindex->nVersion >> bit) & 1) != 0 && ((pindex->nVersion >> bit) & 1) != 0 &&

View File

@ -174,12 +174,12 @@ private:
const Consensus::DeploymentPos id; const Consensus::DeploymentPos id;
protected: protected:
int64_t BeginTime(const Consensus::Params& params) const { return params.vDeployments[id].nStartTime; } int64_t BeginTime(const Consensus::Params& params) const override { return params.vDeployments[id].nStartTime; }
int64_t EndTime(const Consensus::Params& params) const { return params.vDeployments[id].nTimeout; } int64_t EndTime(const Consensus::Params& params) const override { return params.vDeployments[id].nTimeout; }
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; } int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; }
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; } int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; }
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override
{ {
return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask(params)) != 0); return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask(params)) != 0);
} }

View File

@ -157,8 +157,8 @@ public:
bool Lock(); bool Lock();
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret); virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
bool HaveKey(const CKeyID &address) const bool HaveKey(const CKeyID &address) const override
{ {
{ {
LOCK(cs_KeyStore); LOCK(cs_KeyStore);
@ -168,9 +168,9 @@ public:
} }
return false; return false;
} }
bool GetKey(const CKeyID &address, CKey& keyOut) const; bool GetKey(const CKeyID &address, CKey& keyOut) const override;
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const; bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
void GetKeys(std::set<CKeyID> &setAddress) const void GetKeys(std::set<CKeyID> &setAddress) const override
{ {
if (!IsCrypted()) if (!IsCrypted())
{ {

View File

@ -1153,7 +1153,7 @@ public:
void ReturnKey(); void ReturnKey();
bool GetReservedKey(CPubKey &pubkey, bool internal = false); bool GetReservedKey(CPubKey &pubkey, bool internal = false);
void KeepKey(); void KeepKey();
void KeepScript() { KeepKey(); } void KeepScript() override { KeepKey(); }
}; };

View File

@ -24,32 +24,32 @@ public:
*/ */
bool SendMessage(const char *command, const void* data, size_t size); bool SendMessage(const char *command, const void* data, size_t size);
bool Initialize(void *pcontext); bool Initialize(void *pcontext) override;
void Shutdown(); void Shutdown() override;
}; };
class CZMQPublishHashBlockNotifier : public CZMQAbstractPublishNotifier class CZMQPublishHashBlockNotifier : public CZMQAbstractPublishNotifier
{ {
public: public:
bool NotifyBlock(const CBlockIndex *pindex); bool NotifyBlock(const CBlockIndex *pindex) override;
}; };
class CZMQPublishHashTransactionNotifier : public CZMQAbstractPublishNotifier class CZMQPublishHashTransactionNotifier : public CZMQAbstractPublishNotifier
{ {
public: public:
bool NotifyTransaction(const CTransaction &transaction); bool NotifyTransaction(const CTransaction &transaction) override;
}; };
class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier
{ {
public: public:
bool NotifyBlock(const CBlockIndex *pindex); bool NotifyBlock(const CBlockIndex *pindex) override;
}; };
class CZMQPublishRawTransactionNotifier : public CZMQAbstractPublishNotifier class CZMQPublishRawTransactionNotifier : public CZMQAbstractPublishNotifier
{ {
public: public:
bool NotifyTransaction(const CTransaction &transaction); bool NotifyTransaction(const CTransaction &transaction) override;
}; };
#endif // BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H #endif // BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H