update and improve installation

This commit is contained in:
Manuel Araoz 2014-07-29 11:23:30 -03:00
parent 93c47498dc
commit f2542620b2
2 changed files with 51 additions and 49 deletions

View File

@ -99,9 +99,9 @@ In case the network is changed (testnet to livenet or vice versa) levelDB databa
The initial synchronization process scans the blockchain from the paired bitcoind server to update addresses and balances. *insight* needs one (and only one) trusted bitcoind node to run. This node must have finished downloading the blockchain before running *insight*. The initial synchronization process scans the blockchain from the paired bitcoind server to update addresses and balances. *insight* needs one (and only one) trusted bitcoind node to run. This node must have finished downloading the blockchain before running *insight*.
While *insight* is synchronizing the website can be accessed (the sync process is embedded in the webserver), but there may be missing data or incorrect balances for addresses. The 'sync' status is shown on the top-right of all pages. While *insight* is synchronizing the website can be accessed (the sync process is embedded in the webserver), but there may be missing data or incorrect balances for addresses. The 'sync' status is shown at the `/api/sync` endpoint.
The blockchain can be read from bitcoind's raw `.dat` files or RPC interface. Reading the information from the `.dat` files is much faster so it's the recommended (and default) alternative. `.dat` files are scanned in the default location for each platform. In case a non-standard location is used, it needs to be defined (see the Configuration section). The synchronization type being used can be seen at the [Status page](http://localhost:3001/status). As of June 2014, using `.dat` files the sync process takes 9 hrs. for livenet and 30 mins. for testnet. The blockchain can be read from bitcoind's raw `.dat` files or RPC interface. Reading the information from the `.dat` files is much faster so it's the recommended (and default) alternative. `.dat` files are scanned in the default location for each platform (for example, `~/.bitcoin` on Linux). In case a non-standard location is used, it needs to be defined (see the Configuration section). As of June 2014, using `.dat` files the sync process takes 9 hrs. for livenet and 30 mins. for testnet.
While synchronizing the blockchain, *insight* listens for new blocks and transactions relayed by the bitcoind node. Those are also stored on *insight*'s database. In case *insight* is shutdown for a period of time, restarting it will trigger a partial (historic) synchronization of the blockchain. Depending on the size of that synchronization task, a reverse RPC or forward `.dat` syncing strategy will be used. While synchronizing the blockchain, *insight* listens for new blocks and transactions relayed by the bitcoind node. Those are also stored on *insight*'s database. In case *insight* is shutdown for a period of time, restarting it will trigger a partial (historic) synchronization of the blockchain. Depending on the size of that synchronization task, a reverse RPC or forward `.dat` syncing strategy will be used.
@ -121,7 +121,7 @@ If bitcoind is shutdown, *insight* needs to be stopped and restarted once bitcoi
### DB storage requirement ### DB storage requirement
To store the blockchain and address related information, *insight* uses LevelDB. Two DBs are created: txs and blocks. By default these are stored on To store the blockchain and address related information, *insight* uses LevelDB. Two DBs are created: txs and blocks. By default these are stored on
```<user's home>/db``` ```~/.insight/```
Please note that previous version's of Insight-API store that on `<insight's root>/db` Please note that previous version's of Insight-API store that on `<insight's root>/db`
this can be changed on config/config.js. As of June 2014, storing the livenet blockchain takes ~35GB of disk space (2GB for the testnet). this can be changed on config/config.js. As of June 2014, storing the livenet blockchain takes ~35GB of disk space (2GB for the testnet).
@ -137,7 +137,7 @@ To run the tests
```$ grunt test``` ```$ grunt test```
Contributions and suggestions are welcomed at [insight-api github repository](https://github.com/bitpay/insight-api). Contributions and suggestions are welcome at [insight-api github repository](https://github.com/bitpay/insight-api).
## API ## API
@ -170,23 +170,23 @@ Sample return:
``` json ``` json
[ [
{ {
address: "n2PuaAguxZqLddRbTnAoAuwKYgN2w2hZk7", address: "n2PuaAguxZqLddRbTnAoAuwKYgN2w2hZk7",
txid: "dbfdc2a0d22a8282c4e7be0452d595695f3a39173bed4f48e590877382b112fc", txid: "dbfdc2a0d22a8282c4e7be0452d595695f3a39173bed4f48e590877382b112fc",
vout: 0, vout: 0,
ts: 1401276201, ts: 1401276201,
scriptPubKey: "76a914e50575162795cd77366fb80d728e3216bd52deac88ac", scriptPubKey: "76a914e50575162795cd77366fb80d728e3216bd52deac88ac",
amount: 0.001, amount: 0.001,
confirmations: 3 confirmations: 3
}, },
{ {
address: "n2PuaAguxZqLddRbTnAoAuwKYgN2w2hZk7", address: "n2PuaAguxZqLddRbTnAoAuwKYgN2w2hZk7",
txid: "e2b82af55d64f12fd0dd075d0922ee7d6a300f58fe60a23cbb5831b31d1d58b4", txid: "e2b82af55d64f12fd0dd075d0922ee7d6a300f58fe60a23cbb5831b31d1d58b4",
vout: 0, vout: 0,
ts: 1401226410, ts: 1401226410,
scriptPubKey: "76a914e50575162795cd77366fb80d728e3216bd52deac88ac", scriptPubKey: "76a914e50575162795cd77366fb80d728e3216bd52deac88ac",
amount: 0.001, amount: 0.001,
confirmation: 6 confirmation: 6
confirmationsFromCache: true, confirmationsFromCache: true,
} }
] ]
``` ```

View File

@ -1,23 +1,23 @@
'use strict'; 'use strict';
var path = require('path'), var path = require('path'),
fs = require('fs'), fs = require('fs'),
rootPath = path.normalize(__dirname + '/..'), rootPath = path.normalize(__dirname + '/..'),
env, env,
db, db,
port, port,
b_port, b_port,
p2p_port; p2p_port;
var packageStr = fs.readFileSync('package.json'); var packageStr = fs.readFileSync('package.json');
var version = JSON.parse(packageStr).version; var version = JSON.parse(packageStr).version;
function getUserHome() { function getUserHome() {
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
} }
var home = process.env.INSIGHT_DB || ( getUserHome() + '/.insight' ); var home = process.env.INSIGHT_DB || (getUserHome() + '/.insight');
if (process.env.INSIGHT_NETWORK === 'livenet') { if (process.env.INSIGHT_NETWORK === 'livenet') {
env = 'livenet'; env = 'livenet';
@ -25,8 +25,7 @@ if (process.env.INSIGHT_NETWORK === 'livenet') {
port = '3000'; port = '3000';
b_port = '8332'; b_port = '8332';
p2p_port = '8333'; p2p_port = '8333';
} } else {
else {
env = 'testnet'; env = 'testnet';
db = home + '/testnet'; db = home + '/testnet';
port = '3001'; port = '3001';
@ -35,7 +34,7 @@ else {
} }
switch(process.env.NODE_ENV) { switch (process.env.NODE_ENV) {
case 'production': case 'production':
env += ''; env += '';
break; break;
@ -61,11 +60,11 @@ if (!dataDir) {
dataDir += network === 'testnet' ? 'testnet3' : ''; dataDir += network === 'testnet' ? 'testnet3' : '';
var safeConfirmations = process.env.INSIGHT_SAFE_CONFIRMATIONS || 6; var safeConfirmations = process.env.INSIGHT_SAFE_CONFIRMATIONS || 6;
var ignoreCache = process.env.INSIGHT_IGNORE_CACHE || 0; var ignoreCache = process.env.INSIGHT_IGNORE_CACHE || 0;
var bitcoindConf = { var bitcoindConf = {
protocol: process.env.BITCOIND_PROTO || 'http', protocol: process.env.BITCOIND_PROTO || 'http',
user: process.env.BITCOIND_USER || 'user', user: process.env.BITCOIND_USER || 'user',
pass: process.env.BITCOIND_PASS || 'pass', pass: process.env.BITCOIND_PASS || 'pass',
host: process.env.BITCOIND_HOST || '127.0.0.1', host: process.env.BITCOIND_HOST || '127.0.0.1',
@ -79,7 +78,7 @@ var bitcoindConf = {
/*jshint multistr: true */ /*jshint multistr: true */
console.log( console.log(
'\n\ '\n\
____ _ __ __ ___ _ \n\ ____ _ __ __ ___ _ \n\
/ _/___ _____(_)___ _/ /_ / /_ / | ____ (_)\n\ / _/___ _____(_)___ _/ /_ / /_ / | ____ (_)\n\
/ // __ \\/ ___/ / __ `/ __ \\/ __/ / /\| \| / __ \\/ / \n\ / // __ \\/ ___/ / __ `/ __ \\/ __/ / /\| \| / __ \\/ / \n\
@ -104,23 +103,26 @@ console.log(
\nChange setting by assigning the enviroment variables in the last column. Example:\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\ $ INSIGHT_NETWORK="testnet" BITCOIND_HOST="123.123.123.123" ./insight.js\
\n\n', \n\n',
version, version,
network, home, safeConfirmations, ignoreCache?'yes':'no', network, home, safeConfirmations, ignoreCache ? 'yes' : 'no',
bitcoindConf.user, bitcoindConf.user,
bitcoindConf.pass?'Yes(hidden)':'No', bitcoindConf.pass ? 'Yes(hidden)' : 'No',
bitcoindConf.protocol, bitcoindConf.protocol,
bitcoindConf.host, bitcoindConf.host,
bitcoindConf.port, bitcoindConf.port,
bitcoindConf.p2pPort, bitcoindConf.p2pPort,
dataDir+(network==='testnet'?'*':''), dataDir + (network === 'testnet' ? '*' : ''), (network === 'testnet' ? '* (/testnet3 is added automatically)' : '')
(network==='testnet'?'* (/testnet3 is added automatically)':'')
); );
if (! fs.existsSync(db)){ if (!fs.existsSync(db)) {
var err = fs.mkdirSync(db);
console.log('## ERROR ##\n\tDB Directory "%s" not found. \n\tCreate it, move your old DB there or set the INSIGHT_DB environment variable.\n\tNOTE: In older insight-api versions, db was stored at <insight-root>/db', db); if (err) {
process.exit(-1); console.log(err);
console.log("## ERROR! Can't create insight directory! \n");
console.log('\tPlease create it manually: ', db);
process.exit(-1);
}
} }
module.exports = { module.exports = {