From ecf28e085acbc73ea4151b5fcf4921ff06319a91 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 11 Feb 2014 16:30:58 -0300 Subject: [PATCH] environment for run livenet and testnet in same server --- .gitignore | 2 + config/config.js | 41 ++++++++++++------- db/testnet/empty | 0 .../{bitcoin.conf => bitcoin-livenet.conf} | 7 ++-- etc/bitcoind/bitcoin-testnet.conf | 5 +-- 5 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 db/testnet/empty rename etc/bitcoind/{bitcoin.conf => bitcoin-livenet.conf} (59%) diff --git a/.gitignore b/.gitignore index 7f83f84..7eb7357 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,9 @@ npm-debug.log .DS_Store public/lib/* db/txs/* +db/testnet/txs/* db/blocks/* +db/testnet/blocks/* public/js/* public/css/* diff --git a/config/config.js b/config/config.js index cda9349..a27d4d3 100644 --- a/config/config.js +++ b/config/config.js @@ -1,36 +1,47 @@ 'use strict'; -/** - * Module dependencies. - */ var path = require('path'), rootPath = path.normalize(__dirname + '/..'), - env; + env, + db = './db/testnet', + port = '3000', + b_port = '18332', + p2p_port = '18333'; switch(process.env.NODE_ENV) { case 'production': - env = 'prod'; - break; + if (process.env.INSIGHT_NETWORK === 'livenet') { + env = 'livenet'; + db = './db'; + b_port = '8332'; + p2p_port = '8333'; + } + else { + env = 'testnet'; + port = '3001'; + } + break; case 'test': - env = 'test'; - break; + env = 'test environment'; + break; default: - env = 'dev'; - break; + env = 'development'; + break; } + module.exports = { root: rootPath, appName: 'Insight ' + env, - port: process.env.PORT || 3000, - leveldb: './db', + port: port, + leveldb: db, bitcoind: { protocol: process.env.BITCOIND_PROTO || 'http', user: process.env.BITCOIND_USER || 'user', pass: process.env.BITCOIND_PASS || 'pass', host: process.env.BITCOIND_HOST || '127.0.0.1', - port: process.env.BITCOIND_PORT || '18332', - p2pPort: process.env.BITCOIND_P2P_PORT || '18333', - dataDir: process.env.BITCOIND_DATADIR || (process.env.HOME + '/.bitcoin/' + + port: b_port, + p2pPort: p2p_port, + dataDir: (process.env.BITCOIND_DATADIR + ((process.env.INSIGHT_NETWORK || 'testnet')==='testnet'?'testnet3':'')), // DO NOT CHANGE THIS! diff --git a/db/testnet/empty b/db/testnet/empty new file mode 100644 index 0000000..e69de29 diff --git a/etc/bitcoind/bitcoin.conf b/etc/bitcoind/bitcoin-livenet.conf similarity index 59% rename from etc/bitcoind/bitcoin.conf rename to etc/bitcoind/bitcoin-livenet.conf index a939f5a..52e6d08 100644 --- a/etc/bitcoind/bitcoin.conf +++ b/etc/bitcoind/bitcoin-livenet.conf @@ -4,6 +4,7 @@ server=1 txindex=1 # Allow connections outsite localhost? -#rpcallowip=192.168.1.* -#rpcallowip=127.0.0.1 -#rpcallowip=* +rpcallowip=192.168.1.* + +rpcport=8332 + diff --git a/etc/bitcoind/bitcoin-testnet.conf b/etc/bitcoind/bitcoin-testnet.conf index 0de5ed9..99bc260 100644 --- a/etc/bitcoind/bitcoin-testnet.conf +++ b/etc/bitcoind/bitcoin-testnet.conf @@ -4,10 +4,7 @@ server=1 txindex=1 # Allow connections outsite localhost? -#rpcallowip=192.168.1.* -#rpcallowip=127.0.0.1 -#rpcallowip=* +rpcallowip=192.168.1.* -port=18333 rpcport=18332 testnet=3