diff --git a/src/addrdb.h b/src/addrdb.h --- a/src/addrdb.h +++ b/src/addrdb.h @@ -55,7 +55,7 @@ banReason = BanReasonUnknown; } - std::string banReasonToString() { + std::string banReasonToString() const { switch (banReason) { case BanReasonNodeMisbehaving: return "node misbehaving"; diff --git a/src/dbwrapper.h b/src/dbwrapper.h --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -127,7 +127,7 @@ : parent(_parent), piter(_piter){}; ~CDBIterator(); - bool Valid(); + bool Valid() const; void SeekToFirst(); diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -192,7 +192,7 @@ CDBIterator::~CDBIterator() { delete piter; } -bool CDBIterator::Valid() { +bool CDBIterator::Valid() const { return piter->Valid(); } void CDBIterator::SeekToFirst() { diff --git a/src/merkleblock.h b/src/merkleblock.h --- a/src/merkleblock.h +++ b/src/merkleblock.h @@ -67,7 +67,7 @@ * 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.h b/src/miner.h --- a/src/miner.h +++ b/src/miner.h @@ -206,7 +206,7 @@ /** 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, serialized size (if necessary) * These checks should always succeed, and they're here diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -266,7 +266,8 @@ } } -bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOps) { +bool BlockAssembler::TestPackage(uint64_t packageSize, + int64_t packageSigOps) const { auto blockSizeWithPackage = nBlockSize + packageSize; if (blockSizeWithPackage >= nMaxGeneratedBlockSize) { return false; diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -225,7 +225,7 @@ void requestShutdown(Config &config); /// 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 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -33,7 +33,7 @@ // 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) override; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -61,20 +61,20 @@ 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/optionsmodel.cpp b/src/qt/optionsmodel.cpp --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -507,7 +507,7 @@ 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/transactionrecord.h b/src/qt/transactionrecord.h --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -149,7 +149,7 @@ /** Return whether a status update is needed. */ - bool statusUpdateNeeded(); + bool statusUpdateNeeded() const; }; #endif // BITCOIN_QT_TRANSACTIONRECORD_H diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -221,7 +221,7 @@ } } -bool TransactionRecord::statusUpdateNeeded() { +bool TransactionRecord::statusUpdateNeeded() const { AssertLockHeld(cs_main); return status.cur_num_blocks != chainActive.Height(); } diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -83,7 +83,7 @@ int role) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; - bool processingQueuedTransactions() { + bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; } diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -22,15 +22,15 @@ const QList &recipients); ~WalletModelTransaction(); - QList getRecipients(); + QList getRecipients() const; - CWalletTx *getTransaction(); + CWalletTx *getTransaction() const; unsigned int getTransactionSize(); void setTransactionFee(const Amount newFee); - Amount getTransactionFee(); + Amount getTransactionFee() const; - Amount getTotalTransactionAmount(); + Amount getTotalTransactionAmount() const; void newPossibleKeyChange(CWallet *wallet); CReserveKey *getPossibleKeyChange(); diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -18,11 +18,11 @@ delete walletTransaction; } -QList WalletModelTransaction::getRecipients() { +QList WalletModelTransaction::getRecipients() const { return recipients; } -CWalletTx *WalletModelTransaction::getTransaction() { +CWalletTx *WalletModelTransaction::getTransaction() const { return walletTransaction; } @@ -31,7 +31,7 @@ : CTransaction(*walletTransaction).GetTotalSize(); } -Amount WalletModelTransaction::getTransactionFee() { +Amount WalletModelTransaction::getTransactionFee() const { return fee; } @@ -72,7 +72,7 @@ } } -Amount WalletModelTransaction::getTotalTransactionAmount() { +Amount WalletModelTransaction::getTotalTransactionAmount() const { Amount totalTransactionAmount = Amount::zero(); for (const SendCoinsRecipient &rcp : recipients) { totalTransactionAmount += rcp.amount; diff --git a/src/scheduler.h b/src/scheduler.h --- a/src/scheduler.h +++ b/src/scheduler.h @@ -84,7 +84,7 @@ int nThreadsServicingQueue; bool stopRequested; bool stopWhenEmpty; - bool shouldStop() { + bool shouldStop() const { return stopRequested || (stopWhenEmpty && taskQueue.empty()); } }; diff --git a/src/streams.h b/src/streams.h --- a/src/streams.h +++ b/src/streams.h @@ -310,7 +310,7 @@ // 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; } @@ -608,7 +608,7 @@ } // return the current reading position - uint64_t GetPos() { return nReadPos; } + uint64_t GetPos() const { return nReadPos; } // rewind to a given reading position bool SetPos(uint64_t nPos) { diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -92,8 +92,8 @@ 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 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -148,9 +148,9 @@ pre_vector.assign(n, value); } - Size size() { return real_vector.size(); } + Size size() const { return real_vector.size(); } - Size capacity() { return pre_vector.capacity(); } + Size capacity() const { return pre_vector.capacity(); } void shrink_to_fit() { pre_vector.shrink_to_fit(); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -413,7 +413,7 @@ return array; } - std::string GetComment() { return comment; } + std::string GetComment() const { return comment; } }; std::string JSONPrettyPrint(const UniValue &univalue) { diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -726,7 +726,7 @@ 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 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -45,7 +45,7 @@ void Reset(); void MakeMock(); - bool IsMock() { return fMockDb; } + bool IsMock() const { return fMockDb; } /** * Verify that database file strFile is OK. If it is not, call the callback