|
|
@ -1,4 +1,7 @@ |
|
|
|
import { SYNCING_NATIVE_MODE } from '../storeType'; |
|
|
|
import { |
|
|
|
SYNCING_NATIVE_MODE, |
|
|
|
DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE |
|
|
|
} from '../storeType'; |
|
|
|
import { |
|
|
|
triggerToaster, |
|
|
|
getPassthruAgent, |
|
|
@ -7,8 +10,16 @@ import { |
|
|
|
} from '../actionCreators'; |
|
|
|
import Config from '../../config'; |
|
|
|
|
|
|
|
export function nativeGetinfoFailureState() { |
|
|
|
return { |
|
|
|
type: DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 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 )); |
|
|
@ -35,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) { |
|
|
@ -51,23 +66,34 @@ export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) { |
|
|
|
} |
|
|
|
|
|
|
|
function getSyncInfoNativeState(json, coin, skipDebug, skipRemote) { |
|
|
|
if (coin === 'KMD' && |
|
|
|
json && |
|
|
|
json.error && |
|
|
|
json.error.message.indexOf('Activating best') === -1) { |
|
|
|
return getSyncInfoNativeKMD(skipDebug, json, skipRemote); |
|
|
|
/*if (!json.remoteKMDNode) { |
|
|
|
json = { error: { code: -28, message: 'Activating best chain...' } }; |
|
|
|
}*/ |
|
|
|
|
|
|
|
if (json.remoteKMDNode) { |
|
|
|
return { |
|
|
|
type: SYNCING_NATIVE_MODE, |
|
|
|
progress: json, |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (json && |
|
|
|
if (coin === 'KMD' && |
|
|
|
json && |
|
|
|
json.error && |
|
|
|
Config.cli.default) { |
|
|
|
return { |
|
|
|
type: SYNCING_NATIVE_MODE, |
|
|
|
progress: json.error, |
|
|
|
} |
|
|
|
json.error.message.indexOf('Activating best') > -1) { |
|
|
|
return getSyncInfoNativeKMD(skipDebug, json, skipRemote); |
|
|
|
} else { |
|
|
|
return { |
|
|
|
type: SYNCING_NATIVE_MODE, |
|
|
|
progress: json.result ? json.result : json, |
|
|
|
if (json && |
|
|
|
json.error && |
|
|
|
Config.cli.default) { |
|
|
|
return { |
|
|
|
type: SYNCING_NATIVE_MODE, |
|
|
|
progress: json.error, |
|
|
|
} |
|
|
|
} else { |
|
|
|
return { |
|
|
|
type: SYNCING_NATIVE_MODE, |
|
|
|
progress: json.result ? json.result : json, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -156,14 +182,15 @@ export function getSyncInfoNative(coin, skipDebug, skipRemote, suppressErrors) { |
|
|
|
} catch (e) {} |
|
|
|
|
|
|
|
if (!_kmdMainPassiveMode) { |
|
|
|
dispatch( |
|
|
|
dispatch(nativeGetinfoFailureState()); |
|
|
|
/* dispatch( |
|
|
|
triggerToaster( |
|
|
|
'Komodod is down', |
|
|
|
'Critical Error', |
|
|
|
'error', |
|
|
|
true |
|
|
|
) |
|
|
|
); |
|
|
|
); */ |
|
|
|
} else { |
|
|
|
dispatch( |
|
|
|
triggerToaster( |
|
|
|