mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-10 20:56:38 +00:00
Contains bug fixes to get parity to work as a blockchain client. **NOTE:** Please merge https://github.com/embark-framework/embark/pull/1950 first before merging this PR, as this PR contains removal of dependencies from `packages/embark` that are needed for geth. So if this is merged first, and the geth PR (https://github.com/embark-framework/embark/pull/1950) is not merged, then geth will not have some of the dependencies it needs.
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import * as i18n from 'embark-i18n';
|
|
import { ProcessWrapper } from 'embark-core';
|
|
const constants = require('embark-core/constants');
|
|
import { BlockchainClient } from './blockchain';
|
|
|
|
let blockchainProcess;
|
|
|
|
class BlockchainProcess extends ProcessWrapper {
|
|
constructor(options) {
|
|
super();
|
|
this.blockchainConfig = options.blockchainConfig;
|
|
this.client = options.client;
|
|
this.env = options.env;
|
|
this.isDev = options.isDev;
|
|
this.certOptions = options.certOptions;
|
|
|
|
i18n.setOrDetectLocale(options.locale);
|
|
|
|
this.blockchainConfig.silent = true;
|
|
this.blockchain = BlockchainClient(
|
|
this.blockchainConfig,
|
|
{
|
|
clientName: this.client,
|
|
env: this.env,
|
|
certOptions: this.certOptions,
|
|
onReadyCallback: this.blockchainReady.bind(this),
|
|
onExitCallback: this.blockchainExit.bind(this),
|
|
logger: console
|
|
}
|
|
);
|
|
|
|
this.blockchain.run();
|
|
}
|
|
|
|
blockchainReady() {
|
|
blockchainProcess.send({result: constants.blockchain.blockchainReady});
|
|
}
|
|
|
|
blockchainExit() {
|
|
// tell our parent process that ethereum client has exited
|
|
blockchainProcess.send({result: constants.blockchain.blockchainExit});
|
|
}
|
|
|
|
kill() {
|
|
this.blockchain.kill();
|
|
}
|
|
}
|
|
|
|
process.on('message', (msg) => {
|
|
if (msg === 'exit') {
|
|
return blockchainProcess.kill();
|
|
}
|
|
if (msg.action === constants.blockchain.init) {
|
|
blockchainProcess = new BlockchainProcess(msg.options);
|
|
return blockchainProcess.send({result: constants.blockchain.initiated});
|
|
}
|
|
});
|