Merge pull request #489

3adeab8 wallet sync: progressbar ui improvements (Jaquee)
2d6ddf0 Improved blockchain sync status ui (Jaquee)
465f6bf fix daemon startup with --check-updates disabled (Jaquee)
This commit is contained in:
Riccardo Spagni 2017-02-27 22:25:09 +02:00
commit f738b6ac67
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
5 changed files with 32 additions and 10 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

@ -37,11 +37,24 @@ Item {
visible: false
//clip: true
function updateProgress(currentBlock,targetBlock){
function updateProgress(currentBlock,targetBlock, blocksToSync){
if(targetBlock == 1) {
fillLevel = 0
progressText.text = qsTr("Establishing connection...");
progressBar.visible = true
return
}
if(targetBlock > 0) {
var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0);
var remaining = targetBlock - currentBlock
// wallet sync
if(blocksToSync > 0)
var progressLevel = (100*(blocksToSync - remaining)/blocksToSync).toFixed(0);
// Daemon sync
else
var progressLevel = (100*(currentBlock/targetBlock)).toFixed(0);
fillLevel = progressLevel
progressText.text = qsTr("Synchronizing blocks %1/%2").arg(currentBlock.toFixed(0)).arg(targetBlock.toFixed(0));
progressText.text = qsTr("Blocks remaining: %1").arg(remaining.toFixed(0));
progressBar.visible = currentBlock < targetBlock
}
}

View file

@ -66,6 +66,7 @@ ApplicationWindow {
property bool foundNewBlock: false
property int timeToUnlock: 0
property bool qrScannerEnabled: builtWithScanner && (QtMultimedia.availableCameras.length > 0)
property int blocksToSync: 1
// true if wallet ever synchronized
property bool walletInitialized : false
@ -351,10 +352,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
@ -408,7 +409,12 @@ ApplicationWindow {
function onWalletNewBlock(blockHeight, targetHeight) {
// Update progress bar
leftPanel.progressBar.updateProgress(blockHeight,targetHeight);
var remaining = targetHeight - blockHeight;
if(blocksToSync < remaining) {
blocksToSync = remaining;
}
leftPanel.progressBar.updateProgress(blockHeight,targetHeight, blocksToSync);
foundNewBlock = true;
}

View file

@ -44,7 +44,7 @@ bool DaemonManager::start(const QString &flags, bool testnet)
arguments << str;
}
arguments << "--updates" << "disabled";
arguments << "--check-updates" << "disabled";
qDebug() << "starting monerod " + m_monerod;
qDebug() << "With command line arguments " << arguments;

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