embark-area-51/lib/modules/blockchain_process/blockchainProcessLauncher.js
Giuseppe Bertone 81e798c89c
Add support for Parity
Addons
 - New chain initialization and genesis management
 - Option to choose client to use
 - Option to "ping forever" for Geth
 - Creation and unlock of accounts at client's start
 - Utility to fund accounts with ethers
 - Miner settings inside the ethereum client
 - Workaround to CORS problem: origin is now http://embark
 - Several double callback's checks

Updates
 - Boilerplate, templates, configuration files and demo stuff
 - Messages and i18n strings
 - Tests

Fixes
 - Geth client now uses miner.gastarget instead of the deprecated targetGasLimit
 - Workaround for shh_version with Parity

Reworks of other PRs into the new code
 - Included delayed proxy
 - Send ready only when the proxy is started
 - Start HTTP and WS proxies individually
 - Async setupProxy
 - Fixed datadir for GethMiner
2018-10-22 19:53:49 +02:00

70 lines
2.2 KiB
JavaScript

const ProcessLauncher = require('../../core/processes/processLauncher');
const utils = require('../../utils/utils.js');
const constants = require('../../constants');
class BlockchainProcessLauncher {
constructor (options) {
this.events = options.events;
this.logger = options.logger;
this.normalizeInput = options.normalizeInput;
this.blockchainConfig = options.blockchainConfig;
this.locale = options.locale;
this.isDev = options.isDev;
this.client = options.client;
}
processEnded(code) {
this.logger.error(__('Blockchain process ended before the end of this process. Try running blockchain in a separate process using `$ embark blockchain`. Code: %s', code));
}
startBlockchainNode() {
this.logger.info(__('Starting Blockchain node in another process').cyan);
this.blockchainProcess = new ProcessLauncher({
modulePath: utils.joinPath(__dirname, './blockchainProcess.js'),
logger: this.logger,
events: this.events,
silent: this.logger.logLevel !== 'trace',
exitCallback: this.processEnded.bind(this)
});
this.blockchainProcess.send({
action: constants.blockchain.init, options: {
blockchainConfig: this.blockchainConfig,
client: this.client,
env: this.env,
isDev: this.isDev,
locale: this.locale
}
});
this.blockchainProcess.once('result', constants.blockchain.blockchainReady, () => {
this.logger.info(__('Blockchain node is ready').cyan);
this.events.emit(constants.blockchain.blockchainReady);
});
this.blockchainProcess.once('result', constants.blockchain.blockchainExit, () => {
// telle everyone that our blockchain process (ie geth) died
this.events.emit(constants.blockchain.blockchainExit);
// then kill off the blockchain process
this.blockchainProcess.kill();
});
this.events.on('logs:ethereum:enable', () => {
this.blockchainProcess.silent = false;
});
this.events.on('logs:ethereum:disable', () => {
this.blockchainProcess.silent = true;
});
this.events.on('exit', () => {
this.blockchainProcess.send('exit');
});
}
}
module.exports = BlockchainProcessLauncher;