Skip to content

Commit

Permalink
Declare headers height/time cache mutable, re-set the methods const
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Apr 20, 2017
1 parent cf92bce commit 610a917
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/qt/clientmodel.cpp
Expand Up @@ -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
Expand All @@ -87,7 +87,7 @@ int ClientModel::getHeaderTipHeight()
return cachedBestHeaderHeight;
}

int64_t ClientModel::getHeaderTipTime()
int64_t ClientModel::getHeaderTipTime() const
{
if (cachedBestHeaderTime == -1) {
LOCK(cs_main);
Expand Down
8 changes: 4 additions & 4 deletions src/qt/clientmodel.h
Expand Up @@ -51,8 +51,8 @@ class ClientModel : public QObject
//! 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
Expand Down Expand Up @@ -82,8 +82,8 @@ class ClientModel : public QObject
QString dataDir() const;

// caches for the best header
std::atomic<int> cachedBestHeaderHeight;
std::atomic<int64_t> cachedBestHeaderTime;
mutable std::atomic<int> cachedBestHeaderHeight;
mutable std::atomic<int64_t> cachedBestHeaderTime;

private:
OptionsModel *optionsModel;
Expand Down

0 comments on commit 610a917

Please sign in to comment.