diff --git a/src/addrdb.h b/src/addrdb.h index 6cb36dfac4e60..8105ebc9b3dda 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 3e72c5bb9b80b..72eeeef2c3db8 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 7575d207ae5a4..54092f9f597a4 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -130,7 +130,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 f590c487dee0f..20f2b368860ed 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 403d3d4e4a9f7..f1942ec57045b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -224,7 +224,7 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet) } } -bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) +bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const { // TODO: switch to weight-based accounting for packages instead of vsize-based accounting. if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight) diff --git a/src/miner.h b/src/miner.h index 5c9cfd78f0444..685b4e0cc8dd7 100644 --- a/src/miner.h +++ b/src/miner.h @@ -187,7 +187,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, int64_t packageSigOpsCost); + bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const; /** Perform checks on each transaction in a package: * locktime, premature-witness, serialized size (if necessary) * These checks should always succeed, and they're here diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 2b6bd354a0968..3fd58a2f9a0e7 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -227,7 +227,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 21ccdbd8397e2..cda23f9540e89 100644 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -32,7 +32,7 @@ public Q_SLOTS: // will show or hide the modal layer void showHide(bool hide = false, bool userRequested = false); void closeClicked(); - 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 77efef3e3ca26..e9960a01b13d0 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -441,7 +441,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 78529fbdcc921..0ac82a4148b41 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -59,18 +59,18 @@ 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; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } /* Restart flag helper */ void setRestartRequired(bool fRequired); - bool isRestartRequired(); + bool isRestartRequired() const; private: /* Qt-only settings */ diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 2ece0d0f289bb..36d98ce49d0f9 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -248,7 +248,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) status.needsUpdate = false; } -bool TransactionRecord::statusUpdateNeeded() +bool TransactionRecord::statusUpdateNeeded() 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 59f681224fc99..a26e676142531 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -140,7 +140,7 @@ class TransactionRecord /** Return whether a status update is needed. */ - bool statusUpdateNeeded(); + bool statusUpdateNeeded() const; }; #endif // BITCOIN_QT_TRANSACTIONRECORD_H diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index 80aeb64c41d1e..b1f81498b2c2e 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -79,7 +79,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; } private: CWallet* wallet; diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp index 8bc9ef725e4d9..eae2c27f8a491 100644 --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -22,12 +22,12 @@ WalletModelTransaction::~WalletModelTransaction() delete walletTransaction; } -QList WalletModelTransaction::getRecipients() +QList WalletModelTransaction::getRecipients() const { return recipients; } -CWalletTx *WalletModelTransaction::getTransaction() +CWalletTx *WalletModelTransaction::getTransaction() const { return walletTransaction; } @@ -37,7 +37,7 @@ unsigned int WalletModelTransaction::getTransactionSize() return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction)); } -CAmount WalletModelTransaction::getTransactionFee() +CAmount WalletModelTransaction::getTransactionFee() const { return fee; } @@ -79,7 +79,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet) } } -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 64922efada5e5..d7ecd7aa8cdf6 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 0365d668b209b..cc2f01f2ffafe 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 a9668b68bcb17..a3fc919714a9c 100644 --- a/src/streams.h +++ b/src/streams.h @@ -332,7 +332,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; } @@ -648,7 +648,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 4921aedf3993c..ddaf62b3b34c6 100644 --- a/src/sync.h +++ b/src/sync.h @@ -280,7 +280,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 99d0277b7cebb..37ddf83f5ebd7 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 345c4a2148c91..841282873f175 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 06b8274f2d67b..17374edcc4b57 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -450,7 +450,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 6723ea8e6cafc..0b183cbd90113 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -606,7 +606,7 @@ class CTxMemPool return mapTx.size(); } - uint64_t GetTotalTxSize() + uint64_t GetTotalTxSize() const { LOCK(cs); return totalTxSize; diff --git a/src/wallet/db.h b/src/wallet/db.h index 3614e34fbba85..6f3cfe9557042 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -45,7 +45,7 @@ class CDBEnv void Reset(); void MakeMock(); - bool IsMock() { return fMockDb; } + bool IsMock() const { return fMockDb; } /** * Verify that database file strFile is OK. If it is not,