mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 00:07:51 +00:00
Merge pull request #97
d12436a
use daemon target height in progress ui (Jacob Brydolf)8079597
Cache daemon target height (Jacob Brydolf)
This commit is contained in:
commit
cda769739e
3 changed files with 14 additions and 3 deletions
2
main.qml
2
main.qml
|
@ -293,7 +293,7 @@ ApplicationWindow {
|
|||
splashCounter = currHeight
|
||||
var locale = Qt.locale()
|
||||
var currHeightString = currHeight.toLocaleString(locale,"f",0)
|
||||
var targetHeightString = currentWallet.daemonBlockChainHeight().toLocaleString(locale,"f",0)
|
||||
var targetHeightString = currentWallet.daemonBlockChainTargetHeight().toLocaleString(locale,"f",0)
|
||||
var progressText = qsTr("Synchronizing blocks %1 / %2").arg(currHeightString).arg(targetHeightString);
|
||||
console.log("Progress text: " + progressText);
|
||||
splash.heightProgressText = progressText
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include <QTimer>
|
||||
|
||||
namespace {
|
||||
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 60;
|
||||
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 10;
|
||||
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 60;
|
||||
}
|
||||
|
||||
class WalletListenerImpl : public Bitmonero::WalletListener
|
||||
|
@ -169,7 +170,13 @@ quint64 Wallet::daemonBlockChainHeight() const
|
|||
|
||||
quint64 Wallet::daemonBlockChainTargetHeight() const
|
||||
{
|
||||
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();
|
||||
|
||||
if (m_daemonBlockChainTargetHeight == 0
|
||||
|| m_daemonBlockChainTargetHeightTime.elapsed() / 1000 > m_daemonBlockChainTargetHeightTtl) {
|
||||
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();
|
||||
m_daemonBlockChainTargetHeightTime.restart();
|
||||
}
|
||||
|
||||
return m_daemonBlockChainTargetHeight;
|
||||
}
|
||||
|
||||
|
@ -261,6 +268,8 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
|||
, m_historyModel(nullptr)
|
||||
, m_daemonBlockChainHeight(0)
|
||||
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
||||
, m_daemonBlockChainTargetHeight(0)
|
||||
, m_daemonBlockChainTargetHeightTtl(DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS)
|
||||
{
|
||||
m_history = new TransactionHistory(m_walletImpl->history(), this);
|
||||
m_walletImpl->setListener(new WalletListenerImpl(this));
|
||||
|
|
|
@ -172,7 +172,9 @@ private:
|
|||
mutable QTime m_daemonBlockChainHeightTime;
|
||||
mutable quint64 m_daemonBlockChainHeight;
|
||||
int m_daemonBlockChainHeightTtl;
|
||||
mutable QTime m_daemonBlockChainTargetHeightTime;
|
||||
mutable quint64 m_daemonBlockChainTargetHeight;
|
||||
int m_daemonBlockChainTargetHeightTtl;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue