From 610a91719c89f9b52f2ae4a5bd039688fe11ffd7 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 20 Apr 2017 09:51:05 +0200 Subject: [PATCH] Declare headers height/time cache mutable, re-set the methods const --- src/qt/clientmodel.cpp | 4 ++-- src/qt/clientmodel.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 9a8af01a32..cbc6ca1296 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -74,7 +74,7 @@ int ClientModel::getNumBlocks() const return chainActive.Height(); } -int ClientModel::getHeaderTipHeight() +int ClientModel::getHeaderTipHeight() const { if (cachedBestHeaderHeight == -1) { // make sure we initially populate the cache via a cs_main lock @@ -87,7 +87,7 @@ int ClientModel::getHeaderTipHeight() return cachedBestHeaderHeight; } -int64_t ClientModel::getHeaderTipTime() +int64_t ClientModel::getHeaderTipTime() const { if (cachedBestHeaderTime == -1) { LOCK(cs_main); diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 6f7077dad6..0e6b34fbfd 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -51,8 +51,8 @@ public: //! Return number of connections, default is in- and outbound (total) int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; int getNumBlocks() const; - int getHeaderTipHeight(); - int64_t getHeaderTipTime(); + int getHeaderTipHeight() const; + int64_t getHeaderTipTime() const; //! Return number of transactions in the mempool long getMempoolSize() const; //! Return the dynamic memory usage of the mempool @@ -82,8 +82,8 @@ public: QString dataDir() const; // caches for the best header - std::atomic cachedBestHeaderHeight; - std::atomic cachedBestHeaderTime; + mutable std::atomic cachedBestHeaderHeight; + mutable std::atomic cachedBestHeaderTime; private: OptionsModel *optionsModel;