add websocket config to blockchain config

This commit is contained in:
Iuri Matias 2018-01-11 08:55:28 -05:00
parent 471fb1a061
commit 9fd39f36ba
3 changed files with 20 additions and 13 deletions

View File

@ -28,6 +28,7 @@ var Blockchain = function(options) {
maxpeers: ((this.blockchainConfig.maxpeers === 0) ? 0 : (this.blockchainConfig.maxpeers || 25)), maxpeers: ((this.blockchainConfig.maxpeers === 0) ? 0 : (this.blockchainConfig.maxpeers || 25)),
bootnodes: this.blockchainConfig.bootnodes || "", bootnodes: this.blockchainConfig.bootnodes || "",
rpcApi: (this.blockchainConfig.rpcApi || ['eth', 'web3', 'net']), rpcApi: (this.blockchainConfig.rpcApi || ['eth', 'web3', 'net']),
wsRPC: (this.blockchainConfig.wsRPC === undefined) || this.blockchainConfig.wsRPC,
wsHost: this.blockchainConfig.wsHost || 'localhost', wsHost: this.blockchainConfig.wsHost || 'localhost',
wsPort: this.blockchainConfig.wsPort || 8546, wsPort: this.blockchainConfig.wsPort || 8546,
wsOrigins: this.blockchainConfig.wsOrigins || false, wsOrigins: this.blockchainConfig.wsOrigins || false,

View File

@ -96,21 +96,23 @@ class GethCommands {
determineWsOptions(config) { determineWsOptions(config) {
let cmd = ""; let cmd = "";
cmd += "--ws "; if (config.wsRPC) {
cmd += "--wsport " + config.wsPort + " "; cmd += "--ws ";
cmd += "--wsaddr " + config.wsHost + " "; cmd += "--wsport " + config.wsPort + " ";
if (config.wsOrigins) { cmd += "--wsaddr " + config.wsHost + " ";
if (config.wsOrigins === '*') { if (config.wsOrigins) {
if (config.wsOrigins === '*') {
console.log('==================================');
console.log('rpcCorsDomain set to *');
console.log('make sure you know what you are doing');
console.log('==================================');
}
cmd += "--wsorigins \"" + config.wsOrigins + "\" ";
} else {
console.log('=================================='); console.log('==================================');
console.log('rpcCorsDomain set to *'); console.log('warning: cors is not set');
console.log('make sure you know what you are doing');
console.log('=================================='); console.log('==================================');
} }
cmd += "--wsorigins \"" + config.wsOrigins + "\" ";
} else {
console.log('==================================');
console.log('warning: cors is not set');
console.log('==================================');
} }
return cmd; return cmd;

View File

@ -13,7 +13,11 @@
"account": { "account": {
"password": "config/development/password" "password": "config/development/password"
}, },
"wsOrigins": "http://localhost:8000" "wsOrigins": "http://localhost:8000",
"wsRPC": true,
"wsHost": "localhost",
"wsPort": 8546
}, },
"testnet": { "testnet": {
"networkType": "testnet", "networkType": "testnet",