Skip to content

Commit

Permalink
show error when wallet cant start
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBures committed Jun 7, 2017
1 parent df5383c commit 747850e
Show file tree
Hide file tree
Showing 7 changed files with 1,307 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ typings/
cmake-build-debug/
CMakeLists.txt
libs/
helpers.txt
50 changes: 28 additions & 22 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const crypto = require("crypto");
const request = require("request");
const progress = require("request-progress");

let initWalletCount = 0;
let config;
let wallet;
let mainWindow;
Expand All @@ -36,7 +37,7 @@ let data;
function getFileHash(path, callback) {
const hash = crypto.createHash("sha256");
let input;
if (fs.accessSync(path)) {
if (fs.existsSync(path)) {
input = fs.createReadStream(path);
}
else {
Expand All @@ -58,28 +59,28 @@ function fileDownload(url, path, callback) {
return;
}

progress(request(url),{
progress(request(url), {
// throttle: 2000, // Throttle the progress event to 2000ms, defaults to 1000ms
// delay: 1000, // Only start to emit after 1000ms delay, defaults to 0ms
// lengthHeader: 'x-transfer-length' // Length header to use, defaults to content-length
})
.on("progress", function (state) {
paramsPending = true;
downloadProgress.name = url;
downloadProgress.percent = state.percent;
downloadProgress.timeRemaining = state.time.remaining;
})
.on("error", function (err) {
dialog.showErrorBox("Error downloading file", "There was an error trying to download " + downloadProgress.name);
console.log(err);
})
.on("end", function () {
paramsPending = false;
if (typeof callback === "function") {
callback();
}
})
.pipe(fs.createWriteStream(path));
.on("progress", function (state) {
paramsPending = true;
downloadProgress.name = url;
downloadProgress.percent = state.percent;
downloadProgress.timeRemaining = state.time.remaining;
})
.on("error", function (err) {
dialog.showErrorBox("Error downloading file", "There was an error trying to download " + downloadProgress.name);
console.log(err);
})
.on("end", function () {
paramsPending = false;
if (typeof callback === "function") {
callback();
}
})
.pipe(fs.createWriteStream(path));
}

function writeConfig(data) {
Expand Down Expand Up @@ -284,7 +285,11 @@ function startWallet() {
app.quit();
}
else {
console.log("starting wallet");
if(initWalletCount === 10){
dialog.showErrorBox("Wallet daemon can not be run.", "Wallet daemon is not working on your system.");
app.quit();
}
initWalletCount++;
if (!zcashd && (keyVerification.verifying === true && keyVerification.proving === true && configComplete === true)) {
try {
zcashd = spawn(cmd);
Expand Down Expand Up @@ -728,7 +733,6 @@ function createWindow() {
});
}


app.on("ready", function () {
checkConfig(createWindow);
});
Expand Down Expand Up @@ -767,7 +771,9 @@ ipcMain.on("check-config", function () {
});

ipcMain.on("check-params", (event) => {
if ((keyVerification.verifying === false || keyVerification.proving === false)){ checkParams();}
if ((keyVerification.verifying === false || keyVerification.proving === false)) {
checkParams();
}
if (keyVerification.verifyingDownloading === true || keyVerification.provingDownloading === true) {
event.sender.send("params-pending", downloadProgress);
} else {
Expand Down
Loading

0 comments on commit 747850e

Please sign in to comment.