From 5e01a6d1bca6397a8d17ba25a1eafe426e532753 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Thu, 20 Jul 2017 10:14:34 -0700 Subject: [PATCH] activating best chain progress fix --- react/src/actions/actions/nativeSyncInfo.js | 12 +++- .../walletsProgress/walletsProgress.js | 58 ++++++++++++++++++- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/react/src/actions/actions/nativeSyncInfo.js b/react/src/actions/actions/nativeSyncInfo.js index 2bbf5a9..b351e7b 100644 --- a/react/src/actions/actions/nativeSyncInfo.js +++ b/react/src/actions/actions/nativeSyncInfo.js @@ -63,7 +63,8 @@ export function getSyncInfoNativeKMD(skipDebug) { function getSyncInfoNativeState(json, coin, skipDebug) { if (coin === 'KMD' && json && - json.error) { + json.error && + json.error.message.indexOf('Activating best') === -1) { return getSyncInfoNativeKMD(skipDebug); } else { if (json && @@ -71,12 +72,12 @@ function getSyncInfoNativeState(json, coin, skipDebug) { Config.cli.default) { return { type: SYNCING_NATIVE_MODE, - progress: Config.cli.default ? json.error : json, + progress: json.error, } } else { return { type: SYNCING_NATIVE_MODE, - progress: Config.cli.default ? json.result : json, + progress: json.result ? json.result : json, } } } @@ -163,6 +164,11 @@ export function getSyncInfoNative(coin, skipDebug) { json = JSON.parse(json); } + if (json.error && + json.error.message.indexOf('Activating best') === -1) { + dispatch(getDebugLog('komodo', 1)); + } + dispatch(logGuiHttp({ 'timestamp': _timestamp, 'status': 'success', diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.js b/react/src/components/dashboard/walletsProgress/walletsProgress.js index af97464..b63c2a2 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.js @@ -47,7 +47,49 @@ class WalletsProgress extends React.Component { } } + parseActivatingBestChainProgress() { + let _debugLogLine; + + if (this.props.Settings.debugLog.indexOf('\n') > -1) { + const _debugLogMulti = this.props.Settings.debugLog.split('\n'); + + for (let i = 0; i < _debugLogMulti.length; i++) { + if (_debugLogMulti[i].indexOf('progress=') > -1) { + _debugLogLine = _debugLogMulti[i]; + } + } + } else { + _debugLogLine = this.props.Settings.debugLog; + } + + const temp = _debugLogLine.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=', '')) * 1000; + } + } + + return [ + currentBestChain, + currentProgress + ]; + } + renderSyncPercentagePlaceholder() { + // activating best chain + if (this.props.Dashboard.progress && + this.props.Dashboard.progress.code && + this.props.Dashboard.progress.code === -28 && + this.props.Settings.debugLog) { + return SyncPercentageRender.call(this, this.parseActivatingBestChainProgress()[1].toFixed(2)); + } + if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks > 0 && this.props.Dashboard.progress.longestchain === 0) { @@ -120,9 +162,19 @@ class WalletsProgress extends React.Component { } } - return ( - `: ${currentProgress}% (${ translate('INDEX.RESCAN_SM') })` - ); + // activating best chain + if (this.props.Dashboard.progress && + this.props.Dashboard.progress.code && + this.props.Dashboard.progress.code === -28 && + this.props.Settings.debugLog) { + return ( + `: ${this.parseActivatingBestChainProgress()[0]} (current block)` + ); + } else { + return ( + `: ${currentProgress}% (${ translate('INDEX.RESCAN_SM') })` + ); + } } else if ( this.props.Settings.debugLog.indexOf('LoadExternalBlockFile:') > -1 || this.props.Settings.debugLog.indexOf('Reindexing block file') > -1