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.
This commit is contained in:
emizzle 2018-09-19 12:24:30 +10:00
parent 7e52728dc0
commit ab7784c1e9
2 changed files with 4 additions and 3 deletions

View File

@ -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});

View File

@ -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;