Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit 96e8472

Browse files
author
domschiener
committed
Merge branch 'dev'
2 parents 4310a34 + cf54426 commit 96e8472

22 files changed

+245
-66
lines changed

app/js/ccurl-interface.js

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,67 @@
11
var ffi = require('ffi');
2+
var isInitialized = false;
23

34
var ccurlProvider = function(ccurlPath) {
4-
5-
if (!ccurlPath) ccurlPath = __dirname;
5+
if (!ccurlPath) {
6+
console.log("ccurl-interface: no path supplied, returning");
7+
return false;
8+
}
69

710
var fullPath = ccurlPath + '/libccurl';
811

912
try {
1013
// Define libccurl to be used for finding the nonce
11-
return ffi.Library(fullPath, {
12-
ccurl_pow : [ 'string', [ 'string', 'int'] ]
14+
var libccurl = ffi.Library(fullPath, {
15+
ccurl_pow : [ 'string', [ 'string', 'int'] ],
16+
ccurl_pow_finalize : [ 'void', [] ],
17+
ccurl_pow_interrupt: [ 'void', [] ]
1318
});
19+
20+
// Check to make sure the functions are available
21+
if (!libccurl.hasOwnProperty("ccurl_pow") || !libccurl.hasOwnProperty("ccurl_pow_finalize") || !libccurl.hasOwnProperty("ccurl_pow_interrupt")) {
22+
throw new Error("Could not load hashing library.");
23+
}
24+
25+
return libccurl;
1426
} catch (err) {
27+
console.log(err);
1528
return false;
1629
}
1730
}
1831

32+
var ccurlFinalize = function(libccurl) {
33+
if (isInitialized) {
34+
try {
35+
if (libccurl && libccurl.hasOwnProperty("ccurl_pow_finalize")) {
36+
libccurl.ccurl_pow_finalize();
37+
}
38+
} catch (err) {
39+
console.log(err);
40+
}
41+
}
42+
}
43+
44+
var ccurlInterrupt = function(libccurl) {
45+
if (isInitialized) {
46+
try {
47+
if (libccurl && libccurl.hasOwnProperty("ccurl_pow_interrupt")) {
48+
libccurl.ccurl_pow_interrupt();
49+
}
50+
} catch (err) {
51+
console.log(err);
52+
}
53+
}
54+
}
55+
56+
var ccurlInterruptAndFinalize = function(libccurl) {
57+
ccurlInterrupt(libccurl);
58+
ccurlFinalize(libccurl);
59+
}
60+
1961
var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWeightMagnitude, trytes, callback) {
62+
if (!libccurl.hasOwnProperty("ccurl_pow")) {
63+
return callback(new Error("Hashing not available"));
64+
}
2065

2166
// inputValidator: Check if correct hash
2267
if (!iota.validate.isHash(trunkTransaction)) {
@@ -42,6 +87,8 @@ var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWe
4287
// return callback(new Error("Invalid trytes supplied"));
4388
// }
4489

90+
isInitialized = true;
91+
4592
var finalBundleTrytes = [];
4693
var previousTxHash;
4794
var i = 0;
@@ -101,6 +148,8 @@ var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWe
101148

102149
if (error) {
103150
return callback(error);
151+
} else if (returnedTrytes == null) {
152+
return callback("Interrupted");
104153
}
105154

106155
var newTxObject= iota.utils.transactionObject(returnedTrytes);
@@ -129,8 +178,9 @@ var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWe
129178
libccurl.ccurl_pow.async(newTrytes, minWeightMagnitude, function(error, returnedTrytes) {
130179

131180
if (error) {
132-
133181
return callback(error);
182+
} else if (returnedTrytes == null) {
183+
return callback("Interrupted");
134184
}
135185

136186
var newTxObject= iota.utils.transactionObject(returnedTrytes);
@@ -151,5 +201,8 @@ var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWe
151201

152202
module.exports = {
153203
'ccurlProvider': ccurlProvider,
154-
'ccurlHashing': ccurlHashing
204+
'ccurlHashing': ccurlHashing,
205+
'ccurlInterrupt': ccurlInterrupt,
206+
'ccurlFinalize': ccurlFinalize,
207+
'ccurlInterruptAndFinalize': ccurlInterruptAndFinalize
155208
}

app/js/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ var UI = (function(UI, undefined) {
621621
modal.open();
622622
}
623623

624-
UI.relaunchApplication = function() {
625-
electron.ipcRenderer.send("relaunchApplication");
624+
UI.relaunchApplication = function(didFinalize) {
625+
electron.ipcRenderer.send("relaunchApplication", didFinalize);
626626
}
627627

628628
UI.toggleDeveloperTools = function() {
@@ -642,6 +642,8 @@ var UI = (function(UI, undefined) {
642642

643643
if (webviewIsLoaded && webview) {
644644
webview.send(command, args);
645+
} else if (args && args.constructor == Object && args.hasOwnProperty("relaunch") && args.relaunch) {
646+
UI.relaunchApplication(true);
645647
}
646648
}
647649

@@ -831,6 +833,10 @@ electron.ipcRenderer.on("addAndRemoveNeighbors", function(event, addedNodes, rem
831833
UI.sendToWebview("addAndRemoveNeighbors", {"add": addedNodes, "remove": removedNodes});
832834
});
833835

836+
electron.ipcRenderer.on("stopCcurl", function(event, data) {
837+
UI.sendToWebview("stopCcurl", data);
838+
});
839+
834840
electron.ipcRenderer.on("editNodeConfiguration", function(event, serverConfiguration) {
835841
UI.editNodeConfiguration(serverConfiguration);
836842
});

app/js/main.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const powerSaveBlocker = electron.powerSaveBlocker;
77
const shell = electron.shell;
88
const clipboard = electron.clipboard;
99
const pusage = require("pidusage");
10-
const ffi = require('ffi');
1110

1211
let win;
1312
let otherWin;
@@ -57,7 +56,6 @@ var App = (function(App, undefined) {
5756
var didCheckForUpdates = false;
5857
var appVersion = require("../../package.json").version;
5958
var isLookingAtServerLog = false;
60-
var ia32JavaLocation = null;
6159
var is64BitOS = 64;
6260
var rendererPid = null;
6361

@@ -752,8 +750,10 @@ var App = (function(App, undefined) {
752750
if (settings.lightWallet == -1 || (settings.lightWallet == 1 && (!settings.lightWalletHost || !settings.lightWalletPort)) || (settings.lightWallet == 0 && settings.nodes.length == 0)) {
753751
App.showSetupWindow();
754752
} else if (settings.lightWallet == 1) {
753+
global.lightWallet = true;
755754
App.startLightNode();
756755
} else {
756+
global.lightWallet = false;
757757
App.showLoadingWindow();
758758
App.startFullNode();
759759
}
@@ -892,9 +892,6 @@ var App = (function(App, undefined) {
892892
console.log("Found 64-bits java, starting.");
893893
found = true;
894894
App.startFullNodeProcess(location);
895-
} else if (javaVersionOK && !ia32JavaLocation) {
896-
console.log("Found 32-bits java.");
897-
ia32JavaLocation = location;
898895
}
899896
}
900897
});
@@ -928,11 +925,8 @@ var App = (function(App, undefined) {
928925
currentLocationTest++;
929926
if (javaLocations[currentLocationTest]) {
930927
App.checkJavaLocation(javaLocations[currentLocationTest]);
931-
} else if (ia32JavaLocation) {
932-
console.log("Start 32 bit java.");
933-
App.startFullNodeProcess(ia32JavaLocation);
934928
} else {
935-
App.showNoJavaInstalledWindow();
929+
App.showNoJavaInstalledWindow({"java64BitsOK": java64BitsOK});
936930
}
937931
}
938932

@@ -1128,9 +1122,10 @@ var App = (function(App, undefined) {
11281122
}
11291123

11301124
App.switchNodeType = function() {
1125+
/*
11311126
if (win) {
11321127
win.hide();
1133-
}
1128+
}*/
11341129
var lightWallet = settings.lightWallet == 1 ? 0 : 1;
11351130

11361131
if ((lightWallet && (!settings.lightWalletHost || !settings.lightWalletPort)) || (!lightWallet && settings.nodes.length == 0)) {
@@ -1140,7 +1135,17 @@ var App = (function(App, undefined) {
11401135
}
11411136
}
11421137

1143-
App.relaunchApplication = function() {
1138+
App.relaunchApplication = function(didFinalize) {
1139+
console.log("App.relaunchApplication: " + didFinalize);
1140+
// For light wallet, we want to make sure that everything is cleaned properly before restarting..
1141+
if (global.lightWallet && App.windowIsReady && !didFinalize) {
1142+
console.log("Sending stopCcurl message to renderer");
1143+
win.webContents.send("stopCcurl", {"relaunch": true});
1144+
return;
1145+
}
1146+
1147+
console.log("Doing relaunch");
1148+
11441149
App.killNode(function() {
11451150
if (win) {
11461151
win.hide();
@@ -2037,8 +2042,8 @@ electron.app.on("browser-window-blur", function() {
20372042
App.setFocus(false);
20382043
});
20392044

2040-
electron.ipcMain.on("relaunchApplication", function(event, config) {
2041-
App.relaunchApplication(config);
2045+
electron.ipcMain.on("relaunchApplication", function(event, didFinalize) {
2046+
App.relaunchApplication(didFinalize);
20422047
});
20432048

20442049
electron.ipcMain.on("killAlreadyRunningProcessAndRestart", App.killAlreadyRunningProcessAndRestart);

app/js/server-ipc.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
const ipcRenderer = require("electron").ipcRenderer;
2-
const ccurl = require("./ccurl-interface");
2+
var ccurl = false;
3+
4+
//only load for light wallets
5+
if (require("electron").remote.getGlobal("lightWallet")) {
6+
try {
7+
ccurl = require("./ccurl-interface");
8+
} catch (err) {
9+
ccurl = false;
10+
console.log(err);
11+
}
12+
}
313

414
ipcRenderer.on("showNodeInfo", function() {
515
if (typeof(UI) != "undefined") {
@@ -122,6 +132,17 @@ ipcRenderer.on("addAndRemoveNeighbors", function(event, nodes) {
122132
UI.addAndRemoveNeighbors(nodes.add, nodes.remove);
123133
});
124134

135+
ipcRenderer.on("stopCcurl", function(event, callback) {
136+
console.log("in stopCcurl renderer");
137+
if (ccurl && connection.ccurlProvider) {
138+
console.log("calling ccurlInterruptAndFinalize with " + connection.ccurlProvider);
139+
ccurl.ccurlInterruptAndFinalize(connection.ccurlProvider);
140+
}
141+
142+
console.log("Calling relaunchApplication");
143+
ipcRenderer.send("relaunchApplication", true);
144+
});
145+
125146
function _hoverAmountStart(amount) {
126147
ipcRenderer.send("hoverAmountStart", amount);
127148
}
@@ -156,13 +177,16 @@ function _logUINotification(type, message) {
156177
*/
157178

158179
process.once("loaded", function() {
180+
global.backendLoaded = true;
159181
global.updateStatusBar = _updateStatusBar;
160182
global.hoverAmountStart = _hoverAmountStart;
161183
global.hoverAmountStop = _hoverAmountStop;
162184
global.editNodeConfiguration = _editNodeConfiguration;
163185
global.rendererIsReady = _rendererIsReady;
164186
global.relaunchApplication = _relaunchApplication;
165187
global.updateAppInfo = _updateAppInfo;
166-
global.ccurl = ccurl;
188+
if (typeof(ccurl) != "undefined") {
189+
global.ccurl = ccurl;
190+
}
167191
//global.logUINotification = _logUINotification;
168192
});

app/windows/init_error.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ <h1 id="title"></h1>
1313
<p class="label">Server Ouput:</p>
1414
<textarea rows="6" class="form-control" id="server-output" readonly></textarea>
1515
</div>
16-
<div id="download-java-explanation" style="display:none">
17-
<p>Easy solution: Download 64-bit java.</p>
18-
</div>
1916
</div>
2017
</div>
2118
<div id="footer">

app/windows/js/init_error.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ var UI = (function(UI, undefined) {
106106
} else {
107107
document.getElementById("server-output-section").style.display = "none";
108108
}
109-
110-
if (params.is64BitOS && !params.java64BitsOK) {
111-
document.getElementById("download-java-explanation").style.display = "block";
112-
document.getElementById("download-java").style.display = "block";
113-
}
114109
}
115110

116111
electron.remote.getCurrentWindow().setContentSize(600, parseInt(document.documentElement.scrollHeight, 10) + parseInt(document.getElementById("footer").scrollHeight, 10), false);

app/windows/js/no_java.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ var UI = (function(UI, undefined) {
9292
});*/
9393
}
9494

95-
UI.show = function(title, contents, params) {
95+
UI.show = function(params) {
9696
// Only download immediately on windows.
9797
if (params && params.downloadImmediatelyIfWindows && process.platform == "win32") {
9898
document.getElementById("title").innerHTML = "Downloading Java...";
@@ -105,6 +105,10 @@ var UI = (function(UI, undefined) {
105105
electron.remote.getCurrentWindow().setContentSize(600, parseInt(document.documentElement.scrollHeight, 10) + parseInt(document.getElementById("footer").scrollHeight, 10), false);
106106
}
107107

108+
if (params && !params.java64BitsOK) {
109+
document.getElementById("message-64-bit").style.display = "inline";
110+
}
111+
108112
document.body.addEventListener("contextmenu", UI.showContextMenu, false);
109113

110114
setTimeout(function() {
@@ -332,7 +336,7 @@ var UI = (function(UI, undefined) {
332336
document.getElementById("java-download-progress-bar").className += " indeterminate";
333337
electron.remote.getCurrentWindow().setProgressBar(1.1); //set progress bar to indeterminate
334338

335-
// Wait 500 ms before accessing file, it may still be writing to it. Should find a better way!
339+
// Wait 2.5 sec before accessing file, it may still be writing to it. Should find a better way!
336340
setTimeout(function() {
337341
try {
338342
console.log("Installing on windows...");
@@ -358,7 +362,7 @@ var UI = (function(UI, undefined) {
358362
console.log(err);
359363
UI.showMessageAndQuit("Installation Failed", "The installation has failed, please install Java manually. The setup filed is located at " + UI.localDownloadLocation + ".");
360364
}
361-
}, 500);
365+
}, 2500);
362366
} else if (process.platform == "darwin") {
363367
electron.remote.getCurrentWindow().setProgressBar(-1); //remove progress bar
364368
electron.remote.shell.openItem(UI.localDownloadLocation);
@@ -485,6 +489,6 @@ var UI = (function(UI, undefined) {
485489

486490
window.addEventListener("load", UI.initialize, false);
487491

488-
electron.ipcRenderer.on("show", function(event, title, msg, params) {
489-
UI.show(title, msg, params);
492+
electron.ipcRenderer.on("show", function(event, params) {
493+
UI.show(params);
490494
});

app/windows/no_java.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<div class="content">
7171
<h1 id="title">Java Not Found...</h1>
7272
<p id="message">
73-
The correct java version was not found on your system.
73+
The correct java version was not found on your system<span id="message-64-bit" style="font-weight:bold;"> (64-bit Java)</span>.
7474
<span id="message-win">Click on the button below to start downloading. Alternatively you may switch to a Light Node which does not require java.</span>
7575
<span id="message-mac">Click on the button below to start downloading. Reopen the wallet after installation. Alternatively you may switch to a Light Node which does not require java.</span>
7676
<span id="message-lin-default">Click on the button below to start downloading, or install it by typing the following command(s) in the terminal:

build/installer.nsh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
!macro customInstall
2+
;better method ? http://stackoverflow.com/a/26884194
3+
4+
ClearErrors
5+
6+
ReadRegStr $R0 HKLM "SOFTWARE\Classes\Installer\Dependencies\{e46eca4f-393b-40df-9f49-076faf788d83}" "Version"
7+
8+
IfErrors 0 +15
9+
10+
ReadRegStr $R0 HKLM "SOFTWARE\Classes\Installer\Dependencies\{f144e08f-9cbe-4f09-9a8c-f2b858b7ee7f}" "Version"
11+
12+
IfErrors 0 +13
13+
14+
!include x64.nsh
15+
16+
${If} ${RunningX64}
17+
NSISdl::download "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe" "visual_cpp_redistributable.exe"
18+
${Else}
19+
NSISdl::download "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe" "visual_cpp_redistributable.exe"
20+
${EndIf}
21+
22+
Pop $0
23+
24+
${If} $0 == "success"
25+
ExecWait '"visual_cpp_redistributable.exe" /passive /norestart'
26+
${Else}
27+
MessageBox mb_iconstop "Error: $0"
28+
${EndIf}
29+
!macroend

ccurl/lin64/libccurl.so

100755100644
1.25 KB
Binary file not shown.

0 commit comments

Comments
 (0)