Declare headers height/time cache mutable, re-set the methods const

This commit is contained in:
Jonas Schnelli 2017-04-20 09:51:05 +02:00
parent cf92bce526
commit 610a91719c
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
2 changed files with 6 additions and 6 deletions

View File

@ -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);

View File

@ -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<int> cachedBestHeaderHeight;
std::atomic<int64_t> cachedBestHeaderTime;
mutable std::atomic<int> cachedBestHeaderHeight;
mutable std::atomic<int64_t> cachedBestHeaderTime;
private:
OptionsModel *optionsModel;