Improved blockchain sync status ui

This commit is contained in:
Jaquee 2017-02-24 18:07:46 +01:00
parent 465f6bfe27
commit 2d6ddf043e
No known key found for this signature in database
GPG key ID: 384E52B09F45DC39
4 changed files with 15 additions and 5 deletions

View file

@ -48,8 +48,11 @@ Row {
}
function getConnectionStatusString(status) {
if (status == Wallet.ConnectionStatus_Connected)
if (status == Wallet.ConnectionStatus_Connected) {
if(!appWindow.daemonSynced)
return qsTr("Synchronizing")
return qsTr("Connected")
}
if (status == Wallet.ConnectionStatus_WrongVersion)
return qsTr("Wrong version")
if (status == Wallet.ConnectionStatus_Disconnected)

View file

@ -38,6 +38,13 @@ Item {
//clip: true
function updateProgress(currentBlock,targetBlock){
if(targetBlock == 1) {
fillLevel = 0
progressText.text = qsTr("Establishing connection...");
progressBar.visible = true
return
}
if(targetBlock > 0) {
var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0);
fillLevel = progressLevel

View file

@ -351,10 +351,10 @@ ApplicationWindow {
// Check daemon status
var dCurrentBlock = currentWallet.daemonBlockChainHeight();
var dTargetBlock = currentWallet.daemonBlockChainTargetHeight();
// Daemon fully synced
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
daemonSynced = dCurrentBlock >= dTargetBlock
// targetBlock = currentBlock = 1 before network connection is established.
daemonSynced = dCurrentBlock >= dTargetBlock && dTargetBlock != 1
// Update daemon sync progress
leftPanel.progressBar.updateProgress(dCurrentBlock,dTargetBlock);
leftPanel.progressBar.visible = !daemonSynced && currentWallet.connected() !== Wallet.ConnectionStatus_Disconnected

View file

@ -21,7 +21,7 @@
namespace {
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 5;
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 60;
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 30;
static const int WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS = 5;
}
@ -262,7 +262,7 @@ quint64 Wallet::daemonBlockChainHeight() const
quint64 Wallet::daemonBlockChainTargetHeight() const
{
if (m_daemonBlockChainTargetHeight == 0
if (m_daemonBlockChainTargetHeight <= 1
|| m_daemonBlockChainTargetHeightTime.elapsed() / 1000 > m_daemonBlockChainTargetHeightTtl) {
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();