Skip to content

Commit 610a917

Browse files
committed
Declare headers height/time cache mutable, re-set the methods const
1 parent cf92bce commit 610a917

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/qt/clientmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int ClientModel::getNumBlocks() const
7474
return chainActive.Height();
7575
}
7676

77-
int ClientModel::getHeaderTipHeight()
77+
int ClientModel::getHeaderTipHeight() const
7878
{
7979
if (cachedBestHeaderHeight == -1) {
8080
// make sure we initially populate the cache via a cs_main lock
@@ -87,7 +87,7 @@ int ClientModel::getHeaderTipHeight()
8787
return cachedBestHeaderHeight;
8888
}
8989

90-
int64_t ClientModel::getHeaderTipTime()
90+
int64_t ClientModel::getHeaderTipTime() const
9191
{
9292
if (cachedBestHeaderTime == -1) {
9393
LOCK(cs_main);

src/qt/clientmodel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class ClientModel : public QObject
5151
//! Return number of connections, default is in- and outbound (total)
5252
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
5353
int getNumBlocks() const;
54-
int getHeaderTipHeight();
55-
int64_t getHeaderTipTime();
54+
int getHeaderTipHeight() const;
55+
int64_t getHeaderTipTime() const;
5656
//! Return number of transactions in the mempool
5757
long getMempoolSize() const;
5858
//! Return the dynamic memory usage of the mempool
@@ -82,8 +82,8 @@ class ClientModel : public QObject
8282
QString dataDir() const;
8383

8484
// caches for the best header
85-
std::atomic<int> cachedBestHeaderHeight;
86-
std::atomic<int64_t> cachedBestHeaderTime;
85+
mutable std::atomic<int> cachedBestHeaderHeight;
86+
mutable std::atomic<int64_t> cachedBestHeaderTime;
8787

8888
private:
8989
OptionsModel *optionsModel;

0 commit comments

Comments
 (0)