Skip to content

Commit

Permalink
[launcher] Fix SPV choice triggering daemon launch (#2363)
Browse files Browse the repository at this point in the history
This fixes an instance where selecting to use SPV for the first time on a new
install would cause the dcrd full node to run.

The problem was that to speed up the blockchain download, the node was started
after SPV choice and before the wallet tutorial but it was started
unconditionally, without considering the previous choice to only run in SPV
mode.
  • Loading branch information
matheusd authored and alexlyp committed Dec 9, 2019
1 parent 0b8f68f commit 59abd83
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/actions/DaemonActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ export const showPrivacy = () => (dispatch) => {
dispatch(pushHistory("/getstarted/privacy"));
};

export const enableSpv = () => (dispatch, getState) => {
export const enableSpv = () => async (dispatch, getState) => {
dispatch(updateStateSettingsChanged({ spvMode: true }, true));
const tempSettings = getState().settings.tempSettings;
dispatch(saveSettings(tempSettings));
dispatch(finishSpvChoice());
await dispatch(saveSettings(tempSettings));
dispatch(finishSpvChoice(true));
};

export const disableSpv = () => (dispatch, getState) => {
dispatch(updateStateSettingsChanged({ spvMode: false }, true));
const tempSettings = getState().settings.tempSettings;
dispatch(saveSettings(tempSettings));
dispatch(finishSpvChoice());
dispatch(finishSpvChoice(false));
};

export const setupStandardPrivacy = () => (dispatch, getState) => {
Expand All @@ -131,11 +131,13 @@ export const selectLanguage = (selectedLanguage) => (dispatch) => {
dispatch(pushHistory("/getstarted"));
};

export const finishSpvChoice = () => (dispatch) => {
export const finishSpvChoice = (isSPV) => (dispatch) => {
const config = getGlobalCfg();
config.set("show_spvchoice", false);
dispatch({ type: FINISH_SPVCHOICE });
dispatch(startDaemon());
if (!isSPV) {
dispatch(startDaemon());
}
dispatch(goBack());
};

Expand Down

0 comments on commit 59abd83

Please sign in to comment.