Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
should fix #1701
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Mar 9, 2017
1 parent 7ff3f28 commit 0b50df4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion modules/ethereumNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand Down
52 changes: 32 additions & 20 deletions modules/ipc/ipcProviderWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -35,58 +46,61 @@ 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
@method on
@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
@method once
@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) {
Expand All @@ -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;
8 changes: 4 additions & 4 deletions modules/preloader/include/ethereumProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
window.web3 = new Web3(new Web3.providers.IpcProvider('', new ipcProviderWrapper()));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0b50df4

Please sign in to comment.