Skip to content

Commit

Permalink
Use override keyword for overriden class member functions (dashpay#…
Browse files Browse the repository at this point in the history
…1644)

* Use `override` keyword for all overriden functions

* more override
  • Loading branch information
gladcow authored and andvgal committed Dec 25, 2018
1 parent b18577a commit f6bc2c1
Show file tree
Hide file tree
Showing 26 changed files with 84 additions and 82 deletions.
2 changes: 1 addition & 1 deletion src/dsnotificationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CDSNotificationInterface : public CValidationInterface
void AcceptedBlockHeader(const CBlockIndex *pindexNew) override;
void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload) override;
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock);
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) override;

private:
CConnman& connman;
Expand Down
4 changes: 2 additions & 2 deletions src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
{
}
const char* Name()
const char* Name() override
{
return "HTTP";
}
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) override
{
return new HTTPRPCTimer(base, func, millis);
}
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HTTPWorkItem : public HTTPClosure
req(std::move(_req)), path(_path), func(_func)
{
}
void operator()()
void operator()() override
{
func(req.get(), path);
}
Expand Down
26 changes: 13 additions & 13 deletions src/keystore.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class CBasicKeyStore : public CKeyStore
CHDChain hdChain;

public:
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
bool HaveKey(const CKeyID &address) const
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
bool HaveKey(const CKeyID &address) const override
{
bool result;
{
Expand All @@ -75,7 +75,7 @@ class CBasicKeyStore : public CKeyStore
}
return result;
}
void GetKeys(std::set<CKeyID> &setAddress) const
void GetKeys(std::set<CKeyID> &setAddress) const override
{
setAddress.clear();
{
Expand All @@ -88,7 +88,7 @@ class CBasicKeyStore : public CKeyStore
}
}
}
bool GetKey(const CKeyID &address, CKey &keyOut) const
bool GetKey(const CKeyID &address, CKey &keyOut) const override
{
{
LOCK(cs_KeyStore);
Expand All @@ -101,16 +101,16 @@ class CBasicKeyStore : public CKeyStore
}
return false;
}
virtual bool AddCScript(const CScript& redeemScript);
virtual bool HaveCScript(const CScriptID &hash) const;
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const;
virtual bool AddCScript(const CScript& redeemScript) override;
virtual bool HaveCScript(const CScriptID &hash) const override;
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const override;

virtual bool AddWatchOnly(const CScript &dest);
virtual bool RemoveWatchOnly(const CScript &dest);
virtual bool HaveWatchOnly(const CScript &dest) const;
virtual bool HaveWatchOnly() const;
virtual bool AddWatchOnly(const CScript &dest) override;
virtual bool RemoveWatchOnly(const CScript &dest) override;
virtual bool HaveWatchOnly(const CScript &dest) const override;
virtual bool HaveWatchOnly() const override;

bool GetHDChain(CHDChain& hdChainRet) const;
virtual bool GetHDChain(CHDChain& hdChainRet) const;
};

typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;
Expand Down
6 changes: 3 additions & 3 deletions src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class PeerLogicValidation : public CValidationInterface {
PeerLogicValidation(CConnman* connmanIn);
virtual ~PeerLogicValidation() = default;

virtual void SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int nPosInBlock);
virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload);
virtual void BlockChecked(const CBlock& block, const CValidationState& state);
virtual void SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int nPosInBlock) override;
virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
virtual void BlockChecked(const CBlock& block, const CValidationState& state) override;
};

struct CNodeStateStats {
Expand Down
2 changes: 1 addition & 1 deletion src/qt/coincontroltreewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CoinControlTreeWidget : public QTreeWidget
explicit CoinControlTreeWidget(QWidget *parent = 0);

protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyPressEvent(QKeyEvent *event) override;
};

#endif // BITCOIN_QT_COINCONTROLTREEWIDGET_H
4 changes: 2 additions & 2 deletions src/qt/receivecoinsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Q_SLOTS:
void accept();

protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyPressEvent(QKeyEvent *event) override;

private:
Ui::ReceiveCoinsDialog *ui;
Expand All @@ -62,7 +62,7 @@ public Q_SLOTS:

QModelIndex selectedRow();
void copyColumnToClipboard(int column);
virtual void resizeEvent(QResizeEvent *event);
virtual void resizeEvent(QResizeEvent *event) override;

private Q_SLOTS:
void on_receiveButton_clicked();
Expand Down
4 changes: 2 additions & 2 deletions src/qt/receiverequestdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public Q_SLOTS:
void copyImage();

protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void contextMenuEvent(QContextMenuEvent *event) override;

private:
QMenu *contextMenu;
Expand Down
4 changes: 2 additions & 2 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class QtRPCTimerInterface: public RPCTimerInterface
{
public:
~QtRPCTimerInterface() {}
const char *Name() { return "Qt"; }
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
const char *Name() override { return "Qt"; }
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) override
{
return new QtRPCTimerBase(func, millis);
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TransactionView : public QWidget

GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;

virtual void resizeEvent(QResizeEvent* event);
virtual void resizeEvent(QResizeEvent* event) override;

bool eventFilter(QObject *obj, QEvent *event);

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ class submitblock_StateCatcher : public CValidationInterface
submitblock_StateCatcher(const uint256 &hashIn) : hash(hashIn), found(false), state() {}

protected:
virtual void BlockChecked(const CBlock& block, const CValidationState& stateIn) {
virtual void BlockChecked(const CBlock& block, const CValidationState& stateIn) override {
if (block.GetHash() != hash)
return;
found = true;
Expand Down
6 changes: 3 additions & 3 deletions src/script/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class TransactionSignatureChecker : public BaseSignatureChecker

public:
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn) : txTo(txToIn), nIn(nInIn) {}
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const;
bool CheckLockTime(const CScriptNum& nLockTime) const;
bool CheckSequence(const CScriptNum& nSequence) const;
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const override;
bool CheckLockTime(const CScriptNum& nLockTime) const override;
bool CheckSequence(const CScriptNum& nSequence) const override;
};

class MutableTransactionSignatureChecker : public TransactionSignatureChecker
Expand Down
2 changes: 1 addition & 1 deletion src/script/sigcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CachingTransactionSignatureChecker : public TransactionSignatureChecker
public:
CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, bool storeIn=true) : TransactionSignatureChecker(txToIn, nInIn), 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();
Expand Down
2 changes: 1 addition & 1 deletion src/script/sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class DummySignatureChecker : public BaseSignatureChecker
public:
DummySignatureChecker() {}

bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const override
{
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/script/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class TransactionSignatureCreator : public BaseSignatureCreator {

public:
TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, int nHashTypeIn=SIGHASH_ALL);
const BaseSignatureChecker& Checker() const { return checker; }
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const;
const BaseSignatureChecker& Checker() const override{ return checker; }
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const override;
};

/** A signature creator that just produces 72-byte empty signatures. */
class DummySignatureCreator : public BaseSignatureCreator {
public:
DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
const BaseSignatureChecker& Checker() const;
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const;
const BaseSignatureChecker& Checker() const override;
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const override;
};

/** Produce a script signature using a generic signature creator. */
Expand Down
2 changes: 1 addition & 1 deletion src/test/addrman_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CAddrManTest : public CAddrMan
insecure_rand = FastRandomContext(true);
}

int RandomInt(int nMax)
int RandomInt(int nMax) override
{
state = (CHashWriter(SER_GETHASH, 0) << state).GetHash().GetCheapHash();
return (unsigned int)(state % nMax);
Expand Down
4 changes: 2 additions & 2 deletions src/test/net_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CAddrManSerializationMock : public CAddrMan
class CAddrManUncorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s) const
void Serialize(CDataStream& s) const override
{
CAddrMan::Serialize(s);
}
Expand All @@ -37,7 +37,7 @@ class CAddrManUncorrupted : public CAddrManSerializationMock
class CAddrManCorrupted : public CAddrManSerializationMock
{
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.
unsigned char nVersion = 1;
Expand Down
10 changes: 5 additions & 5 deletions src/test/versionbits_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class TestConditionChecker : public AbstractThresholdConditionChecker
mutable ThresholdConditionCache cache;

public:
int64_t BeginTime(const Consensus::Params& params) const { return TestTime(10000); }
int64_t EndTime(const Consensus::Params& params) const { return TestTime(20000); }
int Period(const Consensus::Params& params) const { return 1000; }
int Threshold(const Consensus::Params& params) const { return 900; }
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const { return (pindex->nVersion & 0x100); }
int64_t BeginTime(const Consensus::Params& params) const override { return TestTime(10000); }
int64_t EndTime(const Consensus::Params& params) const override { return TestTime(20000); }
int Period(const Consensus::Params& params) const override { return 1000; }
int Threshold(const Consensus::Params& params) const override { return 900; }
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); }
int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, paramsDummy, cache); }
Expand Down
11 changes: 6 additions & 5 deletions src/txdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CCoinsViewDB : public CCoinsView
public:
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);


bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
bool HaveCoin(const COutPoint &outpoint) const override;
uint256 GetBestBlock() const override;
Expand All @@ -91,12 +92,12 @@ class CCoinsViewDBCursor: public CCoinsViewCursor
public:
~CCoinsViewDBCursor() {}

bool GetKey(COutPoint &key) const;
bool GetValue(Coin &coin) const;
unsigned int GetValueSize() const;
bool GetKey(COutPoint &key) const override;
bool GetValue(Coin &coin) const override;
unsigned int GetValueSize() const override;

bool Valid() const;
void Next();
bool Valid() const override;
void Next() override;

private:
CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256 &hashBlockIn):
Expand Down
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1944,12 +1944,12 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
public:
WarningBitsConditionChecker(int bitIn) : bit(bitIn) {}

int64_t BeginTime(const Consensus::Params& params) const { return 0; }
int64_t EndTime(const Consensus::Params& params) const { return std::numeric_limits<int64_t>::max(); }
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; }
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; }
int64_t BeginTime(const Consensus::Params& params) const override { return 0; }
int64_t EndTime(const Consensus::Params& params) const override { return std::numeric_limits<int64_t>::max(); }
int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; }
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 >> bit) & 1) != 0 &&
Expand Down
6 changes: 3 additions & 3 deletions src/validationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class CValidationInterface {
virtual void Inventory(const uint256 &hash) {}
virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
virtual void BlockChecked(const CBlock&, const CValidationState&) {}
virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {};
virtual void ResetRequestCount(const uint256 &hash) {};
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {}
virtual void ResetRequestCount(const uint256 &hash) {}
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {}
friend void ::RegisterValidationInterface(CValidationInterface*);
friend void ::UnregisterValidationInterface(CValidationInterface*);
friend void ::UnregisterAllValidationInterfaces();
Expand Down
10 changes: 5 additions & 5 deletions src/versionbits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ class VersionBitsConditionChecker : public AbstractThresholdConditionChecker {
const Consensus::DeploymentPos id;

protected:
int64_t BeginTime(const Consensus::Params& params) const { return params.vDeployments[id].nStartTime; }
int64_t EndTime(const Consensus::Params& params) const { return params.vDeployments[id].nTimeout; }
int Period(const Consensus::Params& params) const { return params.vDeployments[id].nWindowSize ? params.vDeployments[id].nWindowSize : params.nMinerConfirmationWindow; }
int Threshold(const Consensus::Params& params) const { return params.vDeployments[id].nThreshold ? params.vDeployments[id].nThreshold : params.nRuleChangeActivationThreshold; }
int64_t BeginTime(const Consensus::Params& params) const override { return params.vDeployments[id].nStartTime; }
int64_t EndTime(const Consensus::Params& params) const override { return params.vDeployments[id].nTimeout; }
int Period(const Consensus::Params& params) const override { return params.vDeployments[id].nWindowSize ? params.vDeployments[id].nWindowSize : params.nMinerConfirmationWindow; }
int Threshold(const Consensus::Params& params) const override { return params.vDeployments[id].nThreshold ? params.vDeployments[id].nThreshold : 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);
}
Expand Down
12 changes: 6 additions & 6 deletions src/wallet/crypter.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ class CCryptoKeyStore : public CBasicKeyStore
bool Lock(bool fAllowMixing = false);

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

bool GetHDChain(CHDChain& hdChainRet) const;
virtual bool GetHDChain(CHDChain& hdChainRet) const override;

/**
* Wallet status (encrypted, locked) changed.
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface

//! Adds a watch-only address to the store, and saves it to disk.
bool AddWatchOnly(const CScript& dest, int64_t nCreateTime);

bool RemoveWatchOnly(const CScript &dest) override;
//! Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
bool LoadWatchOnly(const CScript &dest);
Expand Down Expand Up @@ -1142,7 +1143,7 @@ class CReserveKey : public CReserveScript
void ReturnKey();
bool GetReservedKey(CPubKey &pubkey, bool fInternalIn /*= false*/);
void KeepKey();
void KeepScript() { KeepKey(); }
void KeepScript() override { KeepKey(); }
};


Expand Down
Loading

0 comments on commit f6bc2c1

Please sign in to comment.