diff --git a/modules/ethereumNode.js b/modules/ethereumNode.js index b37c67e8e..a95c28514 100644 --- a/modules/ethereumNode.js +++ b/modules/ethereumNode.js @@ -359,7 +359,7 @@ class EthereumNode extends EventEmitter { // START MAINNET else { args = (nodeType === 'geth') - ? ['--fast', '--cache', '1024'] + ? ['--fast', '--cache', ((process.arch == 'x64') ? '1024' : '512')] : ['--unsafe-transactions']; } diff --git a/modules/ipc/ipcProviderWrapper.js b/modules/ipc/ipcProviderWrapper.js index bb71b87ed..8a4a8d1c9 100644 --- a/modules/ipc/ipcProviderWrapper.js +++ b/modules/ipc/ipcProviderWrapper.js @@ -10,8 +10,15 @@ The IPC provider wrapper to communicate to the backend */ const { ipcRenderer } = require('electron'); +const Socket = require('net').Socket; +const inherits = require('util').inherits; +module.exports = ipcProviderWrapper; + + +inherits(ipcProviderWrapper, Socket); + /** Gets the writable property. @@ -24,8 +31,12 @@ ipcRenderer.on('ipcProvider-setWritable', (e, writable) => { }); -const ipcProviderWrapper = { - writable: false, +function ipcProviderWrapper(){ + Socket.call(this); +}; + +// const ipcProviderWrapper = { + // writable: false, /** Connects the IPC on the backend to the geth node @@ -35,13 +46,14 @@ const ipcProviderWrapper = { @method connect */ - connect(path) { + ipcProviderWrapper.prototype.connect = function(path) { // console.debug('ipcProviderWrapper: connect'); ipcRenderer.send('ipcProvider-create', path); return this; - }, + }; + /** Returns data from the IPC through the backend @@ -49,13 +61,15 @@ const ipcProviderWrapper = { @param {String} name `connect`, `error`, `end`, `timeout` or `data` @param {Funciton} callback */ - on(name, callback) { + ipcProviderWrapper.prototype.on = function(name, callback) { // console.debug('ipcProviderWrapper: add listener', name); ipcRenderer.on(`ipcProvider-${name}`, (e, result) => { + callback(result); }); - }, + }; + ipcProviderWrapper.prototype.addListener = ipcProviderWrapper.prototype.on; /** Returns data from the IPC through the backend @@ -63,30 +77,30 @@ const ipcProviderWrapper = { @param {String} name `connect`, `error`, `end`, `timeout` or `data` @param {Funciton} callback */ - once(name, callback) { + ipcProviderWrapper.prototype.once = function(name, callback) { // console.debug('ipcProviderWrapper: add listener', name); ipcRenderer.once(`ipcProvider-${name}`, (e, result) => { callback(result); }); - }, + }; /** Removes listener @method removeListener */ - removeListener(name, callback) { + ipcProviderWrapper.prototype.removeListener = function(name, callback) { // console.debug('ipcProviderWrapper: remove listener', name); ipcRenderer.removeListener(`ipcProvider-${name}`, callback); - }, + }; /** Removes all listeners @method removeAllListeners */ - removeAllListeners(name) { + ipcProviderWrapper.prototype.removeAllListeners = function(name) { // console.debug('ipcProviderWrapper: remove all listeners', name); if (name) { @@ -97,29 +111,27 @@ const ipcProviderWrapper = { ipcRenderer.removeAllListeners('ipcProvider-timeout'); ipcRenderer.removeAllListeners('ipcProvider-connect'); } - }, + }; /** Write to the IPC connection through the backend @method write */ - write(payload) { + ipcProviderWrapper.prototype.write = function(payload) { // console.debug('ipcProviderWrapper: write payload'); ipcRenderer.send('ipcProvider-write', payload); - }, + }; /** Write synchronous to the IPC connection through the backend + DEPRECATED + @method writeSync */ - writeSync(payload) { + ipcProviderWrapper.prototype.writeSync = function(payload) { // console.debug('ipcProviderWrapper: write payload (sync)'); return ipcRenderer.sendSync('ipcProvider-writeSync', payload); - }, - -}; - + }; -module.exports = ipcProviderWrapper; diff --git a/modules/preloader/include/ethereumProvider.js b/modules/preloader/include/ethereumProvider.js index b41c02dd7..d1f672075 100644 --- a/modules/preloader/include/ethereumProvider.js +++ b/modules/preloader/include/ethereumProvider.js @@ -9,15 +9,15 @@ const ipcProviderWrapper = require('../../ipc/ipcProviderWrapper.js'); const LegacyWeb3IpcProvider = require('./legacyWeb3IpcProvider.js'); -// SET ETHEREUM PROVIDER -window.ethereumProvider = new Web3.providers.IpcProvider('', ipcProviderWrapper); +// SET ETHEREUM PROVIDER !!!! define better provider EthereumProvider send, on, off etc... also improve IPC and WS +// window.ethereumProvider = new Web3.providers.IpcProvider('', new ipcProviderWrapper()); // LEGACY window.BigNumber = BigNumber; window.web3 = { - currentProvider: new LegacyWeb3IpcProvider('', ipcProviderWrapper) + currentProvider: new LegacyWeb3IpcProvider('', new ipcProviderWrapper()) }; // for now still add this too: WILL BE REMOVED with web3 1.0 -window.web3 = new Web3(new Web3.providers.IpcProvider('', ipcProviderWrapper)); \ No newline at end of file +window.web3 = new Web3(new Web3.providers.IpcProvider('', new ipcProviderWrapper())); \ No newline at end of file diff --git a/package.json b/package.json index c89456414..e4e1e7a5f 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "underscore-deep-extend": "^1.1.5", "uuid": "^3.0.1", "web3": "^0.18.2", + "web3-stream-provider": "^2.0.8", "yargs": "^6.6.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 49e1e4676..2ae557ae5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4253,6 +4253,12 @@ wdio-dot-reporter@^0.0.6: dependencies: babel-runtime "^5.8.25" +web3-stream-provider@^2.0.8: + version "2.0.8" + resolved "https://registry.yarnpkg.com/web3-stream-provider/-/web3-stream-provider-2.0.8.tgz#0203719fd5eda16c2caf5850fa4aed5518edeeaa" + dependencies: + readable-stream "^2.0.5" + web3@^0.18.2: version "0.18.2" resolved "https://registry.yarnpkg.com/web3/-/web3-0.18.2.tgz#61b1a6edf5056820e22e1ef082f54c279f4bf758"