Browse Source

Add const to methods that do not modify the object for which it is called

0.16
practicalswift 8 years ago
parent
commit
6e8c48dc59
  1. 2
      src/addrdb.h
  2. 2
      src/dbwrapper.cpp
  3. 2
      src/dbwrapper.h
  4. 2
      src/merkleblock.h
  5. 2
      src/miner.cpp
  6. 2
      src/miner.h
  7. 2
      src/qt/bitcoin.cpp
  8. 2
      src/qt/modaloverlay.h
  9. 2
      src/qt/optionsmodel.cpp
  10. 14
      src/qt/optionsmodel.h
  11. 2
      src/qt/transactionrecord.cpp
  12. 2
      src/qt/transactionrecord.h
  13. 2
      src/qt/transactiontablemodel.h
  14. 8
      src/qt/walletmodeltransaction.cpp
  15. 8
      src/qt/walletmodeltransaction.h
  16. 2
      src/scheduler.h
  17. 4
      src/streams.h
  18. 2
      src/sync.h
  19. 4
      src/test/coins_tests.cpp
  20. 4
      src/test/prevector_tests.cpp
  21. 2
      src/test/script_tests.cpp
  22. 2
      src/txmempool.h
  23. 2
      src/wallet/db.h

2
src/addrdb.h

@ -61,7 +61,7 @@ public:
banReason = BanReasonUnknown; banReason = BanReasonUnknown;
} }
std::string banReasonToString() std::string banReasonToString() const
{ {
switch (banReason) { switch (banReason) {
case BanReasonNodeMisbehaving: case BanReasonNodeMisbehaving:

2
src/dbwrapper.cpp

@ -184,7 +184,7 @@ bool CDBWrapper::IsEmpty()
} }
CDBIterator::~CDBIterator() { delete piter; } CDBIterator::~CDBIterator() { delete piter; }
bool CDBIterator::Valid() { return piter->Valid(); } bool CDBIterator::Valid() const { return piter->Valid(); }
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); } void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }
void CDBIterator::Next() { piter->Next(); } void CDBIterator::Next() { piter->Next(); }

2
src/dbwrapper.h

@ -130,7 +130,7 @@ public:
parent(_parent), piter(_piter) { }; parent(_parent), piter(_piter) { };
~CDBIterator(); ~CDBIterator();
bool Valid(); bool Valid() const;
void SeekToFirst(); void SeekToFirst();

2
src/merkleblock.h

@ -63,7 +63,7 @@ protected:
bool fBad; bool fBad;
/** helper function to efficiently calculate the number of nodes at given height in the merkle tree */ /** 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; return (nTransactions+(1 << height)-1) >> height;
} }

2
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. // TODO: switch to weight-based accounting for packages instead of vsize-based accounting.
if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight) if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight)

2
src/miner.h

@ -187,7 +187,7 @@ private:
/** Remove confirmed (inBlock) entries from given set */ /** Remove confirmed (inBlock) entries from given set */
void onlyUnconfirmed(CTxMemPool::setEntries& testSet); void onlyUnconfirmed(CTxMemPool::setEntries& testSet);
/** Test if a new package would "fit" in the block */ /** 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: /** Perform checks on each transaction in a package:
* locktime, premature-witness, serialized size (if necessary) * locktime, premature-witness, serialized size (if necessary)
* These checks should always succeed, and they're here * These checks should always succeed, and they're here

2
src/qt/bitcoin.cpp

@ -227,7 +227,7 @@ public:
void requestShutdown(); void requestShutdown();
/// Get process return value /// Get process return value
int getReturnValue() { return returnValue; } int getReturnValue() const { return returnValue; }
/// Get window identifier of QMainWindow (BitcoinGUI) /// Get window identifier of QMainWindow (BitcoinGUI)
WId getMainWinId() const; WId getMainWinId() const;

2
src/qt/modaloverlay.h

@ -32,7 +32,7 @@ public Q_SLOTS:
// will show or hide the modal layer // will show or hide the modal layer
void showHide(bool hide = false, bool userRequested = false); void showHide(bool hide = false, bool userRequested = false);
void closeClicked(); void closeClicked();
bool isLayerVisible() { return layerIsVisible; } bool isLayerVisible() const { return layerIsVisible; }
protected: protected:
bool eventFilter(QObject * obj, QEvent * ev); bool eventFilter(QObject * obj, QEvent * ev);

2
src/qt/optionsmodel.cpp

@ -441,7 +441,7 @@ void OptionsModel::setRestartRequired(bool fRequired)
return settings.setValue("fRestartRequired", fRequired); return settings.setValue("fRestartRequired", fRequired);
} }
bool OptionsModel::isRestartRequired() bool OptionsModel::isRestartRequired() const
{ {
QSettings settings; QSettings settings;
return settings.value("fRestartRequired", false).toBool(); return settings.value("fRestartRequired", false).toBool();

14
src/qt/optionsmodel.h

@ -59,18 +59,18 @@ public:
void setDisplayUnit(const QVariant &value); void setDisplayUnit(const QVariant &value);
/* Explicit getters */ /* Explicit getters */
bool getHideTrayIcon() { return fHideTrayIcon; } bool getHideTrayIcon() const { return fHideTrayIcon; }
bool getMinimizeToTray() { return fMinimizeToTray; } bool getMinimizeToTray() const { return fMinimizeToTray; }
bool getMinimizeOnClose() { return fMinimizeOnClose; } bool getMinimizeOnClose() const { return fMinimizeOnClose; }
int getDisplayUnit() { return nDisplayUnit; } int getDisplayUnit() const { return nDisplayUnit; }
QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
bool getProxySettings(QNetworkProxy& proxy) const; bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() { return fCoinControlFeatures; } bool getCoinControlFeatures() const { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
/* Restart flag helper */ /* Restart flag helper */
void setRestartRequired(bool fRequired); void setRestartRequired(bool fRequired);
bool isRestartRequired(); bool isRestartRequired() const;
private: private:
/* Qt-only settings */ /* Qt-only settings */

2
src/qt/transactionrecord.cpp

@ -248,7 +248,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
status.needsUpdate = false; status.needsUpdate = false;
} }
bool TransactionRecord::statusUpdateNeeded() bool TransactionRecord::statusUpdateNeeded() const
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
return status.cur_num_blocks != chainActive.Height() || status.needsUpdate; return status.cur_num_blocks != chainActive.Height() || status.needsUpdate;

2
src/qt/transactionrecord.h

@ -140,7 +140,7 @@ public:
/** Return whether a status update is needed. /** Return whether a status update is needed.
*/ */
bool statusUpdateNeeded(); bool statusUpdateNeeded() const;
}; };
#endif // BITCOIN_QT_TRANSACTIONRECORD_H #endif // BITCOIN_QT_TRANSACTIONRECORD_H

2
src/qt/transactiontablemodel.h

@ -79,7 +79,7 @@ public:
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
bool processingQueuedTransactions() { return fProcessingQueuedTransactions; } bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; }
private: private:
CWallet* wallet; CWallet* wallet;

8
src/qt/walletmodeltransaction.cpp

@ -22,12 +22,12 @@ WalletModelTransaction::~WalletModelTransaction()
delete walletTransaction; delete walletTransaction;
} }
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const
{ {
return recipients; return recipients;
} }
CWalletTx *WalletModelTransaction::getTransaction() CWalletTx *WalletModelTransaction::getTransaction() const
{ {
return walletTransaction; return walletTransaction;
} }
@ -37,7 +37,7 @@ unsigned int WalletModelTransaction::getTransactionSize()
return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction)); return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction));
} }
CAmount WalletModelTransaction::getTransactionFee() CAmount WalletModelTransaction::getTransactionFee() const
{ {
return fee; return fee;
} }
@ -79,7 +79,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
} }
} }
CAmount WalletModelTransaction::getTotalTransactionAmount() CAmount WalletModelTransaction::getTotalTransactionAmount() const
{ {
CAmount totalTransactionAmount = 0; CAmount totalTransactionAmount = 0;
for (const SendCoinsRecipient &rcp : recipients) for (const SendCoinsRecipient &rcp : recipients)

8
src/qt/walletmodeltransaction.h

@ -22,15 +22,15 @@ public:
explicit WalletModelTransaction(const QList<SendCoinsRecipient> &recipients); explicit WalletModelTransaction(const QList<SendCoinsRecipient> &recipients);
~WalletModelTransaction(); ~WalletModelTransaction();
QList<SendCoinsRecipient> getRecipients(); QList<SendCoinsRecipient> getRecipients() const;
CWalletTx *getTransaction(); CWalletTx *getTransaction() const;
unsigned int getTransactionSize(); unsigned int getTransactionSize();
void setTransactionFee(const CAmount& newFee); void setTransactionFee(const CAmount& newFee);
CAmount getTransactionFee(); CAmount getTransactionFee() const;
CAmount getTotalTransactionAmount(); CAmount getTotalTransactionAmount() const;
void newPossibleKeyChange(CWallet *wallet); void newPossibleKeyChange(CWallet *wallet);
CReserveKey *getPossibleKeyChange(); CReserveKey *getPossibleKeyChange();

2
src/scheduler.h

@ -81,7 +81,7 @@ private:
int nThreadsServicingQueue; int nThreadsServicingQueue;
bool stopRequested; bool stopRequested;
bool stopWhenEmpty; bool stopWhenEmpty;
bool shouldStop() { return stopRequested || (stopWhenEmpty && taskQueue.empty()); } bool shouldStop() const { return stopRequested || (stopWhenEmpty && taskQueue.empty()); }
}; };
/** /**

4
src/streams.h

@ -332,7 +332,7 @@ public:
// //
bool eof() const { return size() == 0; } bool eof() const { return size() == 0; }
CDataStream* rdbuf() { return this; } CDataStream* rdbuf() { return this; }
int in_avail() { return size(); } int in_avail() const { return size(); }
void SetType(int n) { nType = n; } void SetType(int n) { nType = n; }
int GetType() const { return nType; } int GetType() const { return nType; }
@ -648,7 +648,7 @@ public:
} }
// return the current reading position // return the current reading position
uint64_t GetPos() { uint64_t GetPos() const {
return nReadPos; return nReadPos;
} }

2
src/sync.h

@ -280,7 +280,7 @@ public:
Release(); Release();
} }
operator bool() operator bool() const
{ {
return fHaveGrant; return fHaveGrant;
} }

4
src/test/coins_tests.cpp

@ -89,8 +89,8 @@ public:
BOOST_CHECK_EQUAL(DynamicMemoryUsage(), ret); BOOST_CHECK_EQUAL(DynamicMemoryUsage(), ret);
} }
CCoinsMap& map() { return cacheCoins; } CCoinsMap& map() const { return cacheCoins; }
size_t& usage() { return cachedCoinsUsage; } size_t& usage() const { return cachedCoinsUsage; }
}; };
} // namespace } // namespace

4
src/test/prevector_tests.cpp

@ -152,11 +152,11 @@ public:
pre_vector.assign(n, value); pre_vector.assign(n, value);
} }
Size size() { Size size() const {
return real_vector.size(); return real_vector.size();
} }
Size capacity() { Size capacity() const {
return pre_vector.capacity(); return pre_vector.capacity();
} }

2
src/test/script_tests.cpp

@ -450,7 +450,7 @@ public:
return array; return array;
} }
std::string GetComment() std::string GetComment() const
{ {
return comment; return comment;
} }

2
src/txmempool.h

@ -606,7 +606,7 @@ public:
return mapTx.size(); return mapTx.size();
} }
uint64_t GetTotalTxSize() uint64_t GetTotalTxSize() const
{ {
LOCK(cs); LOCK(cs);
return totalTxSize; return totalTxSize;

2
src/wallet/db.h

@ -45,7 +45,7 @@ public:
void Reset(); void Reset();
void MakeMock(); void MakeMock();
bool IsMock() { return fMockDb; } bool IsMock() const { return fMockDb; }
/** /**
* Verify that database file strFile is OK. If it is not, * Verify that database file strFile is OK. If it is not,

Loading…
Cancel
Save