Merge pull request #2881

487e706 Improved daemon sync progress bar (rbrunner7)
This commit is contained in:
luigi1111 2020-05-06 00:41:41 -05:00
commit 38612c1285
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
2 changed files with 10 additions and 2 deletions

View file

@ -42,7 +42,7 @@ Rectangle {
function updateProgress(currentBlock,targetBlock, blocksToSync, statusTxt){
if(targetBlock > 0) {
var remaining = (currentBlock < targetBlock) ? targetBlock - currentBlock : 0
var progressLevel = (blocksToSync > 0 && blocksToSync != remaining) ? (100*(blocksToSync - remaining)/blocksToSync).toFixed(0) : (100*(currentBlock / targetBlock)).toFixed(0)
var progressLevel = (blocksToSync > 0 ) ? (100*(blocksToSync - remaining)/blocksToSync).toFixed(0) : 100
fillLevel = progressLevel
if(typeof statusTxt != "undefined" && statusTxt != "") {
progressText.text = statusTxt;

View file

@ -73,6 +73,7 @@ ApplicationWindow {
property bool foundNewBlock: false
property bool qrScannerEnabled: (typeof builtWithScanner != "undefined") && builtWithScanner
property int blocksToSync: 1
property int firstBlockSeen
property bool isMining: false
property int walletMode: persistentSettings.walletMode
property var cameraUi
@ -470,6 +471,9 @@ ApplicationWindow {
console.log("Wallet connection status changed " + status)
middlePanel.updateStatus();
leftPanel.networkStatus.connected = status
if (status == Wallet.ConnectionStatus_Disconnected) {
firstBlockSeen = 0;
}
// Update fee multiplier dropdown on transfer page
middlePanel.transferView.updatePriorityDropdown();
@ -609,18 +613,22 @@ ApplicationWindow {
currentDaemonAddress = localDaemonAddress
currentWallet.initAsync(currentDaemonAddress, isTrustedDaemon());
walletManager.setDaemonAddressAsync(currentDaemonAddress);
firstBlockSeen = 0;
}
function onHeightRefreshed(bcHeight, dCurrentBlock, dTargetBlock) {
// Daemon fully synced
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
// targetBlock = currentBlock = 1 before network connection is established.
if (firstBlockSeen == 0 && dTargetBlock != 1) {
firstBlockSeen = dCurrentBlock;
}
daemonSynced = dCurrentBlock >= dTargetBlock && dTargetBlock != 1
walletSynced = bcHeight >= dTargetBlock
// Update progress bars
if(!daemonSynced) {
leftPanel.daemonProgressBar.updateProgress(dCurrentBlock,dTargetBlock, dTargetBlock-dCurrentBlock);
leftPanel.daemonProgressBar.updateProgress(dCurrentBlock,dTargetBlock, dTargetBlock-firstBlockSeen);
leftPanel.progressBar.updateProgress(0,dTargetBlock, dTargetBlock, qsTr("Waiting for daemon to sync"));
} else {
leftPanel.daemonProgressBar.updateProgress(dCurrentBlock,dTargetBlock, 0, qsTr("Daemon is synchronized (%1)").arg(dCurrentBlock.toFixed(0)));