From f9d718586c4c0df3839846a6c8ba6c5c809d7f68 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Mon, 5 Jun 2017 12:02:47 +0300 Subject: [PATCH] native sync remote node fallback --- .../dashboard/walletsNativeSyncProgress.js | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/react/src/components/dashboard/walletsNativeSyncProgress.js b/react/src/components/dashboard/walletsNativeSyncProgress.js index 15a44e3..0a052c0 100644 --- a/react/src/components/dashboard/walletsNativeSyncProgress.js +++ b/react/src/components/dashboard/walletsNativeSyncProgress.js @@ -31,19 +31,32 @@ class WalletsNativeSyncProgress extends React.Component { renderActivatingBestChainProgress() { if (this.props.Settings && - this.props.Settings.debugLog && - this.props.Dashboard.progress.remoteKMDNode) { + this.props.Settings.debugLog) { if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1) { let temp = this.props.Settings.debugLog.split(' '); let currentBestChain; + let currentProgress; for (let i = 0; i < temp.length; i++) { if (temp[i].indexOf('height=') > -1) { currentBestChain = temp[i].replace('height=', ''); } + if (temp[i].indexOf('progress=') > -1) { + currentProgress = Number(temp[i].replace('progress=', '')) * 100; + } } - return(`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`); + // fallback to local data if remote node is inaccessible + if (this.props.Dashboard.progress.remoteKMDNode && + !this.props.Dashboard.progress.remoteKMDNode.blocks) { + return ( + `: ${currentProgress}%` + ); + } else { + return( + `: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})` + ); + } } else { return ( ... @@ -57,15 +70,15 @@ class WalletsNativeSyncProgress extends React.Component { return _translationComponents.map((_translation) => - {_translation} + { _translation }
); } renderChainActivationNotification() { - if ((this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain) || - this.props.Dashboard.progress.remoteKMDNode) { + if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) || + (this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) { return (