diff --git a/src/addrdb.h b/src/addrdb.h index 4e3b45c3f09504..4a13b29a0fa37f 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -61,7 +61,7 @@ class CBanEntry banReason = BanReasonUnknown; } - std::string banReasonToString() + std::string banReasonToString() const { switch (banReason) { case BanReasonNodeMisbehaving: diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index 703388a4f87efb..ac2de204028077 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -190,7 +190,7 @@ bool CDBWrapper::IsEmpty() } CDBIterator::~CDBIterator() { delete piter; } -bool CDBIterator::Valid() { return piter->Valid(); } +bool CDBIterator::Valid() const { return piter->Valid(); } void CDBIterator::SeekToFirst() { piter->SeekToFirst(); } void CDBIterator::Next() { piter->Next(); } diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 66efca4e4a4501..670b31289f838e 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -139,7 +139,7 @@ class CDBIterator parent(_parent), piter(_piter) { }; ~CDBIterator(); - bool Valid(); + bool Valid() const; void SeekToFirst(); diff --git a/src/merkleblock.h b/src/merkleblock.h index 8a974d4aaaea4f..8e1a35e3de38e7 100644 --- a/src/merkleblock.h +++ b/src/merkleblock.h @@ -63,7 +63,7 @@ class CPartialMerkleTree bool fBad; /** helper function to efficiently calculate the number of nodes at given height in the merkle tree */ - unsigned int CalcTreeWidth(int height) { + unsigned int CalcTreeWidth(int height) const { return (nTransactions+(1 << height)-1) >> height; } diff --git a/src/miner.cpp b/src/miner.cpp index 4911eaf5ae6b14..68aa079b33f593 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -260,7 +260,7 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet) } } -bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOps) +bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOps) const { if (nBlockSize + packageSize >= nBlockMaxSize) return false; diff --git a/src/miner.h b/src/miner.h index 7d64d7f9fa355e..4494d57126fbd7 100644 --- a/src/miner.h +++ b/src/miner.h @@ -186,7 +186,7 @@ class BlockAssembler /** Remove confirmed (inBlock) entries from given set */ void onlyUnconfirmed(CTxMemPool::setEntries& testSet); /** Test if a new package would "fit" in the block */ - bool TestPackage(uint64_t packageSize, unsigned int packageSigOps); + bool TestPackage(uint64_t packageSize, unsigned int packageSigOps) const; /** Perform checks on each transaction in a package: * locktime * These checks should always succeed, and they're here diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index 99566e93410c71..41be48a1cf614c 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -231,7 +231,7 @@ class BitcoinApplication: public QApplication void requestShutdown(); /// Get process return value - int getReturnValue() { return returnValue; } + int getReturnValue() const { return returnValue; } /// Get window identifier of QMainWindow (BitcoinGUI) WId getMainWinId() const; diff --git a/src/qt/modaloverlay.h b/src/qt/modaloverlay.h index d82983ea7dd4cf..71cdadf410ecd8 100644 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -33,7 +33,7 @@ public Q_SLOTS: void showHide(bool hide = false, bool userRequested = false); void closeClicked(); void hideForever(); - bool isLayerVisible() { return layerIsVisible; } + bool isLayerVisible() const { return layerIsVisible; } protected: bool eventFilter(QObject * obj, QEvent * ev); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 155bea8a3a7c70..dc57e7781c0868 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -576,7 +576,7 @@ void OptionsModel::setRestartRequired(bool fRequired) return settings.setValue("fRestartRequired", fRequired); } -bool OptionsModel::isRestartRequired() +bool OptionsModel::isRestartRequired() const { QSettings settings; return settings.value("fRestartRequired", false).toBool(); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 3dd4ff15167d70..fe80d9fdd4fe80 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -68,19 +68,19 @@ class OptionsModel : public QAbstractListModel void setDisplayUnit(const QVariant &value); /* Explicit getters */ - bool getHideTrayIcon() { return fHideTrayIcon; } - bool getMinimizeToTray() { return fMinimizeToTray; } - bool getMinimizeOnClose() { return fMinimizeOnClose; } - int getDisplayUnit() { return nDisplayUnit; } - QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } + bool getHideTrayIcon() const { return fHideTrayIcon; } + bool getMinimizeToTray() const { return fMinimizeToTray; } + bool getMinimizeOnClose() const { return fMinimizeOnClose; } + int getDisplayUnit() const { return nDisplayUnit; } + QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; } bool getProxySettings(QNetworkProxy& proxy) const; - bool getCoinControlFeatures() { return fCoinControlFeatures; } + bool getCoinControlFeatures() const { return fCoinControlFeatures; } bool getShowAdvancedPSUI() { return fShowAdvancedPSUI; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } /* Restart flag helper */ void setRestartRequired(bool fRequired); - bool isRestartRequired(); + bool isRestartRequired() const; bool resetSettings; private: diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index c2d180093e600b..716b9a1ef34666 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -363,7 +363,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx, int chainLockHeight) status.needsUpdate = false; } -bool TransactionRecord::statusUpdateNeeded(int chainLockHeight) +bool TransactionRecord::statusUpdateNeeded(int chainLockHeight) const { AssertLockHeld(cs_main); return status.cur_num_blocks != chainActive.Height() || status.needsUpdate diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 309f3fd005f48f..2b6c64c7e93a67 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -166,7 +166,7 @@ class TransactionRecord /** Return whether a status update is needed. */ - bool statusUpdateNeeded(int chainLockHeight); + bool statusUpdateNeeded(int chainLockHeight) const; }; #endif // BITCOIN_QT_TRANSACTIONRECORD_H diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index 3f2d3a2f4defea..62a8077f2e85a9 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -86,7 +86,7 @@ class TransactionTableModel : public QAbstractTableModel QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; - bool processingQueuedTransactions() { return fProcessingQueuedTransactions; } + bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; } void updateChainLockHeight(int chainLockHeight); int getChainLockHeight() const; diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp index a8a9feb4d08d86..d11c17ea0d3ee8 100644 --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -21,12 +21,12 @@ WalletModelTransaction::~WalletModelTransaction() delete walletTransaction; } -QList WalletModelTransaction::getRecipients() +QList WalletModelTransaction::getRecipients() const { return recipients; } -CWalletTx *WalletModelTransaction::getTransaction() +CWalletTx *WalletModelTransaction::getTransaction() const { return walletTransaction; } @@ -36,7 +36,7 @@ unsigned int WalletModelTransaction::getTransactionSize() return (!walletTransaction ? 0 : (::GetSerializeSize(walletTransaction->tx, SER_NETWORK, PROTOCOL_VERSION))); } -CAmount WalletModelTransaction::getTransactionFee() +CAmount WalletModelTransaction::getTransactionFee() const { return fee; } @@ -85,7 +85,7 @@ void WalletModelTransaction::reassignAmounts() } } -CAmount WalletModelTransaction::getTotalTransactionAmount() +CAmount WalletModelTransaction::getTotalTransactionAmount() const { CAmount totalTransactionAmount = 0; for (const SendCoinsRecipient &rcp : recipients) diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h index e3eabcc2abcc16..c21aec69974723 100644 --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -22,15 +22,15 @@ class WalletModelTransaction explicit WalletModelTransaction(const QList &recipients); ~WalletModelTransaction(); - QList getRecipients(); + QList getRecipients() const; - CWalletTx *getTransaction(); + CWalletTx *getTransaction() const; unsigned int getTransactionSize(); void setTransactionFee(const CAmount& newFee); - CAmount getTransactionFee(); + CAmount getTransactionFee() const; - CAmount getTotalTransactionAmount(); + CAmount getTotalTransactionAmount() const; void newPossibleKeyChange(CWallet *wallet); CReserveKey *getPossibleKeyChange(); diff --git a/src/scheduler.h b/src/scheduler.h index 0365d668b209b8..cc2f01f2ffafea 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -81,7 +81,7 @@ class CScheduler int nThreadsServicingQueue; bool stopRequested; bool stopWhenEmpty; - bool shouldStop() { return stopRequested || (stopWhenEmpty && taskQueue.empty()); } + bool shouldStop() const { return stopRequested || (stopWhenEmpty && taskQueue.empty()); } }; /** diff --git a/src/streams.h b/src/streams.h index 88ae1fe740cb49..375d474bc54421 100644 --- a/src/streams.h +++ b/src/streams.h @@ -289,7 +289,7 @@ class CDataStream // bool eof() const { return size() == 0; } CDataStream* rdbuf() { return this; } - int in_avail() { return size(); } + int in_avail() const { return size(); } void SetType(int n) { nType = n; } int GetType() const { return nType; } @@ -605,7 +605,7 @@ class CBufferedFile } // return the current reading position - uint64_t GetPos() { + uint64_t GetPos() const { return nReadPos; } diff --git a/src/sync.h b/src/sync.h index 90ae3c9634a8dd..864d427e1cef18 100644 --- a/src/sync.h +++ b/src/sync.h @@ -283,7 +283,7 @@ class CSemaphoreGrant Release(); } - operator bool() + operator bool() const { return fHaveGrant; } diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 1dee71de46aa52..99c4f7428f1b26 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -89,8 +89,8 @@ class CCoinsViewCacheTest : public CCoinsViewCache BOOST_CHECK_EQUAL(DynamicMemoryUsage(), ret); } - CCoinsMap& map() { return cacheCoins; } - size_t& usage() { return cachedCoinsUsage; } + CCoinsMap& map() const { return cacheCoins; } + size_t& usage() const { return cachedCoinsUsage; } }; } // namespace diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 4b6a29d9885706..6baab42f1eb742 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -152,11 +152,11 @@ class prevector_tester { pre_vector.assign(n, value); } - Size size() { + Size size() const { return real_vector.size(); } - Size capacity() { + Size capacity() const { return pre_vector.capacity(); } diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index a80644d8ad9141..71565ce5a5797d 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -377,7 +377,7 @@ class TestBuilder return array; } - std::string GetComment() + std::string GetComment() const { return comment; } diff --git a/src/txmempool.h b/src/txmempool.h index e6b90e3481ad7c..123a85d1df9d3f 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -642,7 +642,7 @@ class CTxMemPool return mapTx.size(); } - uint64_t GetTotalTxSize() + uint64_t GetTotalTxSize() const { LOCK(cs); return totalTxSize;