diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..dfef2ce18 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "editor.tabSize": 2, + "workbench.activityBar.visible": true, + "editor.minimap.enabled": false +} \ No newline at end of file diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index bc6934633..7ca0608ed 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -170,15 +170,9 @@ Blockchain.prototype.run = function() { // Geth logs appear in stderr somehow self.child.stderr.on('data', (data) => { data = data.toString(); - if (self.onReadyCallback && !self.readyCalled && data.indexOf('WebSocket endpoint opened') > -1) { - if (self.isDev) { - self.createFundAndUnlockAccounts((err) => { - // TODO: this is never called! - if(err) console.error('Error creating, unlocking, and funding accounts', err); - }); - } + if (!self.readyCalled && data.indexOf('WebSocket endpoint opened') > -1) { self.readyCalled = true; - self.onReadyCallback(); + self.readyCallback(); } console.log('Geth: ' + data); }); @@ -212,6 +206,29 @@ Blockchain.prototype.createFundAndUnlockAccounts = function(cb) { cb(err); }); }); +} + +Blockchain.prototype.readyCallback = function() { + if (this.onReadyCallback) { + this.onReadyCallback(); + } + + const NetcatClient = require('netcat/client'); + + + var nc2 = new NetcatClient(); + nc2.unixSocket('/home/jonathan/dapp-bin/embark_demo/.embark/development/datadir/geth.ipc') + .enc('utf8') + .on('data', function(res){ + console.log(res); + }) + .connect() + .send(JSON.stringify({"jsonrpc":"2.0","method":"rpc_modules","params":[],"id":1})); + + setTimeout(() => { + console.log('Stop miner'); + nc2.send(JSON.stringify({"jsonrpc":"2.0","method":"miner_stop","params":[],"id":1})); + }, 5000); }; Blockchain.prototype.kill = function() { diff --git a/lib/core/ipc.js b/lib/core/ipc.js index e84e88abc..07106e57d 100644 --- a/lib/core/ipc.js +++ b/lib/core/ipc.js @@ -16,8 +16,8 @@ class IPC { function connecting(_socket) { let connectedBefore = false, alreadyDisconnected = false; ipc.of['embark'].on('connect',function() { + if (!alreadyDisconnected && !connectedBefore) { connectedBefore = true; - if (!alreadyDisconnected) { self.connected = true; done(); } diff --git a/package-lock.json b/package-lock.json index 837f1f50d..296ca5e1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -233,6 +233,11 @@ "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" }, + "ansi-color": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ansi-color/-/ansi-color-0.2.1.tgz", + "integrity": "sha1-PnXAN0dSF1RO12Oo21cJ+prlv5o=" + }, "ansi-escapes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", @@ -416,6 +421,11 @@ "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=" }, + "async-each-series": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/async-each-series/-/async-each-series-1.1.0.tgz", + "integrity": "sha1-9C/YFV048hpbjqB8KOBj7RcAsTg=" + }, "async-eventemitter": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", @@ -2585,6 +2595,11 @@ } } }, + "datagram-stream": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/datagram-stream/-/datagram-stream-1.1.1.tgz", + "integrity": "sha1-qn2ElZo6GxpeQ9THwDRh9AqP+30=" + }, "date-fns": { "version": "1.29.0", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz", @@ -5576,6 +5591,29 @@ "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" }, + "hexer": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/hexer/-/hexer-1.5.0.tgz", + "integrity": "sha1-uGzoCFmOip0YksVx887dhvyfBlM=", + "requires": { + "ansi-color": "^0.2.1", + "minimist": "^1.1.0", + "process": "^0.10.0", + "xtend": "^4.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "process": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/process/-/process-0.10.1.tgz", + "integrity": "sha1-hCRXzFHP7XLcd1r+6vuMYDQ3JyU=" + } + } + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -6787,6 +6825,11 @@ "graceful-fs": "^4.1.9" } }, + "lasync": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/lasync/-/lasync-1.1.0.tgz", + "integrity": "sha1-vlTTnnS9/Hys2mHrwkGZFMsXdGI=" + }, "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", @@ -8366,6 +8409,11 @@ "resolved": "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz", "integrity": "sha1-DMj20OK2IrR5xA1JnEbWS3Vcb18=" }, + "nanoid": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.0.4.tgz", + "integrity": "sha512-zWPAK2WibMbVda1DvhYbahj7DAXLMvSI4Ik7553nPyJ2p8I5qJr4/j/6kgHJalrOx4FRbbme2Oa6utdzr6I/tA==" + }, "nanomatch": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", @@ -8435,6 +8483,29 @@ "resolved": "https://registry.npmjs.org/neo-blessed/-/neo-blessed-0.2.0.tgz", "integrity": "sha512-C2kC4K+G2QnNQFXUIxTQvqmrdSIzGTX1ZRKeDW6ChmvPRw8rTkTEJzbEQHiHy06d36PCl/yMOCjquCRV8SpSQw==" }, + "netcat": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/netcat/-/netcat-1.3.5.tgz", + "integrity": "sha512-ZpKBhbwWsTNg5HD5CZ7UZ/9Sjrzqfos40eoeDLoGckLSmmif23xUOSJ8EfJaF1V5xetwBpanrQjqD3mXBU6JEQ==", + "requires": { + "async-each-series": "^1.1.0", + "datagram-stream": "^1.1.1", + "debug": "^3.1.0", + "hexer": "^1.5.0", + "nanoid": "^1.0.2", + "through2": "^2.0.3" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -8632,6 +8703,22 @@ } } }, + "node-netcat": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/node-netcat/-/node-netcat-1.4.8.tgz", + "integrity": "sha1-pbqVwlJD//v1InDexlrASf3zcCE=", + "requires": { + "lasync": "~1.1.0", + "underscore": "~1.6.0" + }, + "dependencies": { + "underscore": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=" + } + } + }, "node-object-hash": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/node-object-hash/-/node-object-hash-1.4.1.tgz", diff --git a/package.json b/package.json index 12ad976dc..7d348faa7 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,10 @@ "merge": "^1.2.0", "mocha": "^3.2.0", "neo-blessed": "^0.2.0", + "netcat": "^1.3.5", "node-http-proxy": "^0.2.3", "node-ipc": "^9.1.1", + "node-netcat": "^1.4.8", "ora": "^2.1.0", "os-locale": "^2.1.0", "parse-json": "^4.0.0", diff --git a/test_apps/test_app/config/blockchain.json b/test_apps/test_app/config/blockchain.json index e92186eb0..b61dcc9d9 100644 --- a/test_apps/test_app/config/blockchain.json +++ b/test_apps/test_app/config/blockchain.json @@ -3,7 +3,7 @@ "enabled": true, "networkType": "custom", "networkId": "1337", - "isDev": true, + "isDev": false, "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", "mineWhenNeeded": true,