Skip to content

Commit

Permalink
add report when starting insight
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu committed May 26, 2014
1 parent 09baa94 commit 1636e84
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 14 deletions.
63 changes: 51 additions & 12 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var path = require('path'),
b_port,
p2p_port;

var packageStr = fs.readFileSync('package.json');
var version = JSON.parse(packageStr).version;


function getUserHome() {
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
Expand Down Expand Up @@ -55,8 +58,54 @@ if (!dataDir) {
if (isMac) dataDir = process.env.HOME + '/Library/Application Support/Bitcoin/';
if (isLinux) dataDir = process.env.HOME + '/.bitcoin/';
}
var odataDir = dataDir;

dataDir += network === 'testnet' ? 'testnet3' : '';

var safeConfirmations = process.env.SAFE_CONFIRMATIONS || 6;


var bitcoindConf = {
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 || b_port,
p2pPort: process.env.BITCOIND_P2P_PORT || p2p_port,
dataDir: dataDir,
// DO NOT CHANGE THIS!
disableAgent: true
};

/*jshint multistr: true */
console.log(
'\n Insight API v%s\n\
\n # Configuration:\n\
\t\tNetwork: %s\tINSIGHT_NETWORK\n\
\t\tDatabase Path: %s\tINSIGHT_DB\n\
\t\tSafe Confirmations: %s\tSAFE_CONFIRMATIONS\n\
# Bicoind Connection configuration:\n\
\t\tRPC Username: %s\tBITCOIND_USER\n\
\t\tRPC Password: %s\tBITCOIND_PASS\n\
\t\tRPC Protocol: %s\tBITCOIND_PROTO\n\
\t\tRPC Host: %s\tBITCOIND_HOST\n\
\t\tRPC Port: %s\tBITCOIND_PORT\n\
\t\tP2P Port: %s\tBITCOIND_P2P_PORT\n\
\t\tData Dir: %s\tBITCOIND_DATADIR\n\
\nChange setting by assigning the enviroment variables in the last column. Example:\n\
$ INSIGHT_NETWORK="testnet" BITCOIND_HOST="123.123.123.123" ./insight.js\
\n\n',
version,
network, home, safeConfirmations,
bitcoindConf.user,
bitcoindConf.pass?'Yes(hidden)':'No',
bitcoindConf.protocol,
bitcoindConf.host,
bitcoindConf.port,
bitcoindConf.p2p_port,
odataDir
);


if (! fs.existsSync(db)){

Expand All @@ -71,17 +120,7 @@ module.exports = {
apiPrefix: '/api',
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 || b_port,
p2pPort: process.env.BITCOIND_P2P_PORT || p2p_port,
dataDir: dataDir,
// DO NOT CHANGE THIS!
disableAgent: true
},
bitcoind: bitcoindConf,
network: network,
disableP2pSync: false,
disableHistoricSync: false,
Expand All @@ -92,5 +131,5 @@ module.exports = {
keys: {
segmentio: process.env.INSIGHT_SEGMENTIO_KEY
},
safeConfirmations: 6, // PLEASE NOTE THAT *FULL RESYNC* IS NEEDED TO CHANGE safeConfirmations
safeConfirmations: safeConfirmations, // PLEASE NOTE THAT *FULL RESYNC* IS NEEDED TO CHANGE safeConfirmations
};
4 changes: 2 additions & 2 deletions insight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

#!/usr/bin/env node

'use strict';
//Set the node enviornment variable if not set before
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

Expand Down

0 comments on commit 1636e84

Please sign in to comment.