sync progress improvements

This commit is contained in:
Jaquee 2017-01-31 10:34:18 +01:00
parent eb909e1ae7
commit 2586404339
4 changed files with 17 additions and 21 deletions

View file

@ -42,7 +42,7 @@ Item {
var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0); var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0);
fillLevel = progressLevel fillLevel = progressLevel
progressText.text = qsTr("Synchronizing blocks %1/%2").arg(currentBlock.toFixed(0)).arg(targetBlock.toFixed(0)); progressText.text = qsTr("Synchronizing blocks %1/%2").arg(currentBlock.toFixed(0)).arg(targetBlock.toFixed(0));
item.visible = (currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (currentBlock < targetBlock) progressBar.visible = currentBlock < targetBlock
} }
} }

View file

@ -54,7 +54,6 @@ ApplicationWindow {
property var transaction; property var transaction;
property var transactionDescription; property var transactionDescription;
property alias password : passwordDialog.password property alias password : passwordDialog.password
property int splashCounter: 0
property bool isNewWallet: false property bool isNewWallet: false
property int restoreHeight:0 property int restoreHeight:0
property bool daemonSynced: false property bool daemonSynced: false
@ -261,10 +260,12 @@ ApplicationWindow {
return path.replace(/.*[\/\\]/, '').replace(/\.keys$/, '') return path.replace(/.*[\/\\]/, '').replace(/\.keys$/, '')
} }
function onWalletConnectionStatusChanged(){ function onWalletConnectionStatusChanged(status){
console.log("Wallet connection status changed") console.log("Wallet connection status changed")
middlePanel.updateStatus(); middlePanel.updateStatus();
} leftPanel.networkStatus.connected = status
leftPanel.progressBar.visible = (status === Wallet.ConnectionStatus_Connected) && !daemonSynced
}
function onWalletOpened(wallet) { function onWalletOpened(wallet) {
walletName = usefulName(wallet.path) walletName = usefulName(wallet.path)
@ -306,7 +307,6 @@ ApplicationWindow {
console.log(">>> wallet updated") console.log(">>> wallet updated")
middlePanel.unlockedBalanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(currentWallet.unlockedBalance); middlePanel.unlockedBalanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(currentWallet.unlockedBalance);
middlePanel.balanceText = leftPanel.balanceText = walletManager.displayAmount(currentWallet.balance); middlePanel.balanceText = leftPanel.balanceText = walletManager.displayAmount(currentWallet.balance);
console.log("time to unlock: ", currentWallet.history.minutesToUnlock);
// Update history if new block found since last update and balance is locked. // Update history if new block found since last update and balance is locked.
if(foundNewBlock && currentWallet.history.locked) { if(foundNewBlock && currentWallet.history.locked) {
foundNewBlock = false; foundNewBlock = false;
@ -332,11 +332,16 @@ ApplicationWindow {
// Daemon fully synced // Daemon fully synced
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced // TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) daemonSynced = dCurrentBlock >= dTargetBlock
// Update daemon sync progress
leftPanel.progressBar.updateProgress(dCurrentBlock,dTargetBlock); leftPanel.progressBar.updateProgress(dCurrentBlock,dTargetBlock);
updateSyncing((currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (dCurrentBlock < dTargetBlock)) leftPanel.progressBar.visible = !daemonSynced && currentWallet.connected !== Wallet.ConnectionStatus_Disconnected
// Update wallet sync progress
updateSyncing((currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && !daemonSynced)
// Update transfer page status
middlePanel.updateStatus(); middlePanel.updateStatus();
// If wallet isnt connected and no daemon is running - Ask // If wallet isnt connected and no daemon is running - Ask
if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){ if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){
daemonManagerDialog.open(); daemonManagerDialog.open();
@ -388,17 +393,10 @@ ApplicationWindow {
daemonRunning = false; daemonRunning = false;
} }
function onWalletNewBlock(blockHeight) { function onWalletNewBlock(blockHeight, targetHeight) {
// Update progress bar // Update progress bar
var currHeight = blockHeight leftPanel.progressBar.updateProgress(blockHeight,targetHeight);
//fast refresh until restoreHeight is reached foundNewBlock = true;
var increment = ((restoreHeight == 0) || currHeight < restoreHeight)? 1000 : 10
if(currHeight > splashCounter + increment){
splashCounter = currHeight
leftPanel.progressBar.updateProgress(currHeight,currentWallet.daemonBlockChainTargetHeight());
}
foundNewBlock = true;
} }
function onWalletMoneyReceived(txId, amount) { function onWalletMoneyReceived(txId, amount) {
@ -708,7 +706,6 @@ ApplicationWindow {
// close wallet and show wizard // close wallet and show wizard
function showWizard(){ function showWizard(){
walletInitialized = false; walletInitialized = false;
splashCounter = 0;
closeWallet(); closeWallet();
currentWallet = undefined; currentWallet = undefined;
wizard.restart(); wizard.restart();

View file

@ -655,7 +655,6 @@ Rectangle {
//TODO: enable send page when we're connected and daemon is synced //TODO: enable send page when we're connected and daemon is synced
function updateStatus() { function updateStatus() {
console.log("updated transfer page status")
if(typeof currentWallet === "undefined") { if(typeof currentWallet === "undefined") {
statusText.text = qsTr("Wallet is not connected to daemon.") + "<br>" + root.startLinkText statusText.text = qsTr("Wallet is not connected to daemon.") + "<br>" + root.startLinkText
return; return;

View file

@ -127,9 +127,9 @@ void Wallet::updateConnectionStatusAsync()
Wallet::ConnectionStatus Wallet::connected(bool forceCheck) Wallet::ConnectionStatus Wallet::connected(bool forceCheck)
{ {
qDebug() << "Checking connection status";
// cache connection status // cache connection status
if (forceCheck || !m_initialized || (m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl && !m_connectionStatusRunning) || m_connectionStatusTime.elapsed() > 30000) { if (forceCheck || !m_initialized || (m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl && !m_connectionStatusRunning) || m_connectionStatusTime.elapsed() > 30000) {
qDebug() << "Checking connection status";
m_connectionStatusRunning = true; m_connectionStatusRunning = true;
m_initialized = true; m_initialized = true;
m_connectionStatusTime.restart(); m_connectionStatusTime.restart();