use blockchain config to determine rpc host and port

This commit is contained in:
Iuri Matias 2016-08-26 07:51:58 -04:00
parent e9e71da81a
commit f38d0e886c
3 changed files with 18 additions and 11 deletions

View File

@ -1,8 +1,9 @@
var ABIGenerator = function(contractsManager) {
var ABIGenerator = function(blockchainConfig, contractsManager) {
this.blockchainConfig = blockchainConfig;
this.contractsManager = contractsManager;
this.rpcHost = 'localhost';
this.rpcPort = '8545';
this.rpcHost = blockchainConfig.rpcHost;
this.rpcPort = blockchainConfig.rpcPort;
};
ABIGenerator.prototype.generateProvider = function() {

View File

@ -1,7 +1,8 @@
var mkdirp = require('mkdirp');
var wrench = require('wrench');
var Blockchain = function() {
var Blockchain = function(blockchainConfig) {
this.blockchainConfig = blockchainConfig;
};
Blockchain.prototype.run = function(options) {
@ -101,8 +102,8 @@ Blockchain.prototype.generate_basic_command = function() {
cmd += "--port " + "30303" + " ";
cmd += "--rpc ";
cmd += "--rpcport " + 8545 + " ";
cmd += "--rpcaddr " + "localhost" + " ";
cmd += "--rpcport " + this.blockchainConfig.rpcPort + " ";
cmd += "--rpcaddr " + this.blockchainConfig.rpcHost + " ";
cmd += "--networkid " + "12301" + " ";
cmd += "--rpccorsdomain=\"" + "*" + "\" ";
@ -170,9 +171,9 @@ Blockchain.prototype.getStartChainCommand = function(use_tmp) {
};
var BlockchainClient = function(client) {
var BlockchainClient = function(blockchainConfig, client) {
if (client === 'geth') {
return new Blockchain();
return new Blockchain(blockchainConfig);
} else {
throw new Error('unknown client');
}

View File

@ -90,7 +90,7 @@ var Embark = {
},
blockchain: function(env, client) {
var blockchain = Blockchain(client);
var blockchain = Blockchain(this.config.blockchainConfig, client);
blockchain.run({env: env});
},
@ -107,15 +107,20 @@ var Embark = {
callback(null, contractsManager);
},
function deployContracts(contractsManager, callback) {
//TODO: figure out where to put this since the web3 can be passed along if needed
// perhaps it should go into the deploy object itself
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
var web3Endpoint = 'http://' + self.config.blockchainConfig.rpcHost + ':' + self.config.blockchainConfig.rpcPort;
web3.setProvider(new web3.providers.HttpProvider(web3Endpoint));
var deploy = new Deploy(web3, contractsManager);
deploy.deployAll(function() {
callback(null, contractsManager);
});
},
function generateABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(contractsManager);
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
callback(null, abiGenerator.generateABI());
},
], function(err, result) {