Browse Source

activating best chain progress handling fix

all-modes
pbca26 7 years ago
parent
commit
32c33cb4e1
  1. 23
      react/src/actions/actions/nativeSyncInfo.js
  2. 17
      react/src/components/dashboard/walletsProgress/walletsProgress.js
  3. 5
      react/src/components/dashboard/walletsProgress/walletsProgress.render.js
  4. 2
      react/src/reducers/activeCoin.js

23
react/src/actions/actions/nativeSyncInfo.js

@ -18,6 +18,8 @@ export function nativeGetinfoFailureState() {
// TODO: use debug.log instead
export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) {
let _json = json;
if (skipRemote) {
return dispatch => {
dispatch(getSyncInfoNativeState(Config.iguanaLessMode ? json.info : json ));
@ -44,11 +46,15 @@ export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) {
)
);*/
console.warn('remote kmd node fetch failed', true);
dispatch(getSyncInfoNativeState({ remoteKMDNode: null }));
_json = _json.error;
_json['remoteKMDNode'] = null;
dispatch(getSyncInfoNativeState(_json));
})
.then(response => response.json())
.then(json => {
dispatch(getSyncInfoNativeState({ remoteKMDNode: Config.iguanaLessMode ? json.info : json }));
_json = _json.error;
_json['remoteKMDNode'] = json.info;
dispatch(getSyncInfoNativeState(_json));
})
.then(function() {
if (!skipDebug) {
@ -60,10 +66,20 @@ export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) {
}
function getSyncInfoNativeState(json, coin, skipDebug, skipRemote) {
/*if (!json.remoteKMDNode) {
json = { error: { code: -28, message: 'Activating best chain...' } };
}*/
if (json.remoteKMDNode) {
return {
type: SYNCING_NATIVE_MODE,
progress: json,
}
} else {
if (coin === 'KMD' &&
json &&
json.error &&
json.error.message.indexOf('Activating best') === -1) {
json.error.message.indexOf('Activating best') > -1) {
return getSyncInfoNativeKMD(skipDebug, json, skipRemote);
} else {
if (json &&
@ -81,6 +97,7 @@ function getSyncInfoNativeState(json, coin, skipDebug, skipRemote) {
}
}
}
}
export function getSyncInfoNative(coin, skipDebug, skipRemote, suppressErrors) {
let payload = {

17
react/src/components/dashboard/walletsProgress/walletsProgress.js

@ -107,16 +107,29 @@ class WalletsProgress extends React.Component {
}
if (temp[i].indexOf('progress=') > -1) {
currentProgress = Number(temp[i].replace('progress=', '')) * 1000;
currentProgress = currentProgress >= 100 ? 100 : currentProgress;
if (currentProgress > 100) {
currentProgress = Number(temp[i].replace('progress=', '')) * 100;
}
}
}
if (this.props.ActiveCoin.progress.remoteKMDNode &&
this.props.ActiveCoin.progress.remoteKMDNode.blocks) {
const longestHeight = this.props.ActiveCoin.progress.remoteKMDNode.blocks;
return [
currentBestChain,
currentProgress,
longestHeight
];
} else {
return [
currentBestChain,
currentProgress
];
}
}
}
renderSyncPercentagePlaceholder() {
const _progress = this.props.ActiveCoin.progress;
@ -131,7 +144,7 @@ class WalletsProgress extends React.Component {
if (_parseProgress &&
_parseProgress[1]) {
return SyncPercentageRender.call(this, _parseProgress[1] === 1000 ? 100 : _parseProgress[1].toFixed(2));
return SyncPercentageRender.call(this, _parseProgress[1].toFixed(2) + '%', _parseProgress[0], _parseProgress[2] ? _parseProgress[2] : null);
} else {
return LoadingBlocksRender.call(this);
}

5
react/src/components/dashboard/walletsProgress/walletsProgress.render.js

@ -17,7 +17,7 @@ export const SyncErrorBlocksRender = function() {
);
};
export const SyncPercentageRender = function(syncPercentage) {
export const SyncPercentageRender = function(syncPercentage, currentBlock, maxHeight) {
if (this.props.ActiveCoin.rescanInProgress) {
return (
<div
@ -36,11 +36,12 @@ export const SyncPercentageRender = function(syncPercentage) {
</div>
);
} else {
// if (this.props.ActiveCoin.progress)
return (
<div
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent"
style={{ width: syncPercentage }}>
<span style={{ width: syncPercentage }}>{ syncPercentage === '100.00%' ? '100%' : syncPercentage } | { this.props.ActiveCoin.progress.blocks } / { this.props.ActiveCoin.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections }</span>
<span style={{ width: syncPercentage }}>{ syncPercentage === '100.00%' ? '100%' : syncPercentage } | { this.props.ActiveCoin.progress.blocks || currentBlock } / { this.props.ActiveCoin.progress.longestchain || maxHeight } <span className={ this.props.ActiveCoin.progress.connections ? '' : 'hide' }>| { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections }</span></span>
</div>
);
}

2
react/src/reducers/activeCoin.js

@ -228,8 +228,6 @@ export function ActiveCoin(state = {
getinfoFetchFailures: !action.progress ? state.getinfoFetchFailures + 1 : 0,
};
case DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE:
console.warn('_getinfoFetchFailures', state.getinfoFetchFailures + 1);
return {
...state,
getinfoFetchFailures: state.getinfoFetchFailures + 1,

Loading…
Cancel
Save