From ab7784c1e97b7151989c3069bdd79d8a08985519 Mon Sep 17 00:00:00 2001 From: emizzle Date: Wed, 19 Sep 2018 12:24:30 +1000 Subject: [PATCH 1/2] Fix datadir for miner The datadir path was not being passed to the miner, was resolving as `undefined`, and therefore, was not setting up an ipc connection correctly and no communication was happening. The fix passes the `datadir` from the blockchain config to the miner in the constructor. --- lib/modules/blockchain_process/blockchain.js | 4 ++-- lib/modules/blockchain_process/miner.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/modules/blockchain_process/blockchain.js b/lib/modules/blockchain_process/blockchain.js index 90e4a161..f5c3f85d 100644 --- a/lib/modules/blockchain_process/blockchain.js +++ b/lib/modules/blockchain_process/blockchain.js @@ -231,7 +231,7 @@ Blockchain.prototype.readyCallback = function() { if (this.config.mineWhenNeeded && !this.isDev) { const GethMiner = require('./miner'); - this.miner = new GethMiner(); + this.miner = new GethMiner({datadir: this.blockchainConfig.datadir}); } }; @@ -316,7 +316,7 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) { }; var BlockchainClient = function(blockchainConfig, client, env, onReadyCallback, onExitCallback) { - const isDev = blockchainConfig.isDev || blockchainConfig.default; + const isDev = Boolean(blockchainConfig.isDev); // TODO add other clients at some point if (client === 'geth') { return new Blockchain({blockchainConfig, client: GethCommands, env, isDev, onReadyCallback, onExitCallback}); diff --git a/lib/modules/blockchain_process/miner.js b/lib/modules/blockchain_process/miner.js index 16590a10..79f132b8 100644 --- a/lib/modules/blockchain_process/miner.js +++ b/lib/modules/blockchain_process/miner.js @@ -13,11 +13,12 @@ const getChanges = 'eth_getFilterChanges'; const getBlockCount = 'eth_getBlockTransactionCountByNumber'; class GethMiner { - constructor() { + constructor(options) { const self = this; // TODO: Find a way to load mining config from YML. // In the meantime, just set an empty config object this.config = {}; + this.datadir = options.datadir; self.interval = null; self.callback = null; self.started = null; From 4a321e3c0c55a8dadeacff00d4400460e90317c3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 19 Sep 2018 12:25:50 -0400 Subject: [PATCH 2/2] coerce boolean value using more commmon !! --- lib/modules/blockchain_process/blockchain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/blockchain_process/blockchain.js b/lib/modules/blockchain_process/blockchain.js index f5c3f85d..83da2fef 100644 --- a/lib/modules/blockchain_process/blockchain.js +++ b/lib/modules/blockchain_process/blockchain.js @@ -316,7 +316,7 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) { }; var BlockchainClient = function(blockchainConfig, client, env, onReadyCallback, onExitCallback) { - const isDev = Boolean(blockchainConfig.isDev); + const isDev = !!blockchainConfig.isDev; // TODO add other clients at some point if (client === 'geth') { return new Blockchain({blockchainConfig, client: GethCommands, env, isDev, onReadyCallback, onExitCallback});