Skip to content

Commit

Permalink
Add daemon_rpc_host_testnet and use for start rpc (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp authored Jul 25, 2017
1 parent 1a069c0 commit 4f43279
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/actions/WalletLoaderActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { loader } from '../middleware/grpc/client';
import { getWalletServiceAttempt, getTicketBuyerServiceAttempt, getAgendaServiceAttempt, getVotingServiceAttempt } from './ClientActions';
import { getVersionServiceAttempt } from './VersionActions';
import { getSeederAttempt, generateRandomSeedAttempt } from './SeedServiceActions';
import { getCfg, getCfgPath, getDcrdCert } from '../config.js';
import { getCfg, getCfgPath, getDcrdCert,RPCDaemonPort, RPCDaemonHost } from '../config.js';
import { WalletExistsRequest, CreateWalletRequest, OpenWalletRequest,
CloseWalletRequest, StartConsensusRpcRequest, DiscoverAddressesRequest,
SubscribeToBlockNotificationsRequest, FetchHeadersRequest } from '../middleware/walletrpc/api_pb';
Expand Down Expand Up @@ -175,12 +175,8 @@ function startRpcError(error, request) {

export function startRpcRequestFunc(localHost) {
var cfg = getCfg();
var rpcport = '';
if (cfg.get('network') == 'testnet') {
rpcport = cfg.get('daemon_port_testnet');
} else {
rpcport = cfg.get('daemon_port');
}
var rpcport = RPCDaemonPort();
var daemonhost = RPCDaemonHost();
var request = new StartConsensusRpcRequest();

// This is an attempt to deal with different setups
Expand All @@ -194,7 +190,7 @@ export function startRpcRequestFunc(localHost) {
dispatch(startRpcAction(request, true));
};
} else {
request.setNetworkAddress('127.0.0.1:' + rpcport);
request.setNetworkAddress(daemonhost + ':' + rpcport);
request.setUsername(cfg.get('rpc_user'));
request.setPassword(new Uint8Array(Buffer.from(cfg.get('rpc_pass'))));
request.setCertificate(new Uint8Array(getDcrdCert()));
Expand Down
12 changes: 12 additions & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export function getCfg(update) {
if (!config.has('daemon_rpc_host')) {
config.set('daemon_rpc_host', '127.0.0.1');
}
if (!config.has('daemon_rpc_host_testnet')) {
config.set('daemon_rpc_host_testnet', '127.0.0.1');
}
if (!config.has('wallet_rpc_host')) {
config.set('wallet_rpc_host', '127.0.0.1');
}
Expand Down Expand Up @@ -229,6 +232,15 @@ export function RPCDaemonPort() {
return cfg.get('daemon_port_testnet');
}

export function RPCDaemonHost() {
var cfg = getCfg();
if (cfg.get('network') == 'mainnet') {
return cfg.get('daemon_rpc_host');
}
return cfg.get('daemon_rpc_host_testnet');
}


export function dcrdCfg() {
var cfgLoc = appDataDirectory();
return path.join(cfgLoc, 'dcrd.conf');
Expand Down

0 comments on commit 4f43279

Please sign in to comment.