mirror of https://github.com/embarklabs/embark.git
simplify blockchain constructor
This commit is contained in:
parent
0e03d8f435
commit
b5ff1add40
|
@ -5,9 +5,10 @@ var fs = require('../../core/fs.js');
|
|||
|
||||
var GethCommands = require('./geth_commands.js');
|
||||
|
||||
var Blockchain = function(blockchainConfig, Client, env) {
|
||||
this.blockchainConfig = blockchainConfig;
|
||||
this.env = env || 'development';
|
||||
var Blockchain = function(options) {
|
||||
this.blockchainConfig = options.blockchainConfig;
|
||||
this.env = options.env || 'development';
|
||||
this.client = options.client;
|
||||
|
||||
this.config = {
|
||||
geth_bin: this.blockchainConfig.geth_bin || 'geth',
|
||||
|
@ -30,7 +31,7 @@ var Blockchain = function(blockchainConfig, Client, env) {
|
|||
vmdebug: this.blockchainConfig.vmdebug || false
|
||||
};
|
||||
|
||||
this.client = new Client({config: this.config, env: this.env});
|
||||
this.client = new options.client({config: this.config, env: this.env});
|
||||
};
|
||||
|
||||
Blockchain.prototype.runCommand = function(cmd) {
|
||||
|
@ -80,7 +81,7 @@ Blockchain.prototype.initChainAndGetAddress = function() {
|
|||
|
||||
var BlockchainClient = function(blockchainConfig, client, env) {
|
||||
if (client === 'geth') {
|
||||
return new Blockchain(blockchainConfig, GethCommands, env);
|
||||
return new Blockchain({blockchainConfig: blockchainConfig, client: GethCommands, env: env});
|
||||
} else {
|
||||
throw new Error('unknown client');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue