From fb712091b55680427369d64b092fc6fe9ebae655 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 17 Apr 2014 09:30:49 -0300 Subject: [PATCH 1/5] update dependencies versions --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 51426677..d0a130bf 100644 --- a/package.json +++ b/package.json @@ -50,13 +50,13 @@ "start": "node node_modules/grunt-cli/bin/grunt" }, "dependencies": { - "bitcore": "git://github.com/bitpay/bitcore.git#9ef8b781826eac502783ff74b3dc2949cfc237ed", + "bitcore": "=0.1.8", "base58-native": "0.1.2", "async": "*", "leveldown": "*", "levelup": "*", "glob": "*", - "soop": "git://github.com/gasteve/node-soop.git", + "soop": "=0.1.3", "commander": "*", "bignum": "*", "express": "~3.4.7", @@ -66,8 +66,8 @@ "moment": "~2.5.0", "sinon": "~1.7.3", "chai": "~1.8.1", - "bufferput": "git://github.com/bitpay/node-bufferput.git", "xmlhttprequest": "~1.6.0" + "bufferput": "git://github.com/bitpay/node-bufferput.git", }, "devDependencies": { "grunt": "~0.4.2", From a4eda616596054dc23b3dfbc0de9cef58c54001c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 17 Apr 2014 09:32:49 -0300 Subject: [PATCH 2/5] move DB out of insight directory --- README.md | 3 ++- config/config.js | 19 +++++++++++++++++-- lib/TransactionDb.js | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 31dba97c..fa84d193 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,8 @@ If bitcoind is shutdown, *insight* needs to be stopped and restarted once bitcoi ### 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 - ```/db``` + ```/db``` +Please note that previous version's of Insight-API store that on `/db` this can be changed on config/config.js. As of February 2014, storing the livenet blockchain takes ~30GB of disk space (2GB for the testnet). diff --git a/config/config.js b/config/config.js index bb020097..f59a8f2f 100644 --- a/config/config.js +++ b/config/config.js @@ -1,6 +1,7 @@ 'use strict'; var path = require('path'), + fs = require('fs'), rootPath = path.normalize(__dirname + '/..'), env, db, @@ -8,16 +9,23 @@ var path = require('path'), b_port, p2p_port; + +function getUserHome() { + return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; +} + +var home = process.env.INSIGHT_DB || ( getUserHome() + '/insight-api-db' ); + if (process.env.INSIGHT_NETWORK === 'livenet') { env = 'livenet'; - db = rootPath + '/db'; + db = home; port = '3000'; b_port = '8332'; p2p_port = '8333'; } else { env = 'testnet'; - db = rootPath + '/db/testnet'; + db = home + '/testnet'; port = '3001'; b_port = '18332'; p2p_port = '18333'; @@ -48,6 +56,13 @@ if (!dataDir) { } dataDir += network === 'testnet' ? 'testnet3' : ''; + +if (! fs.existsSync(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 /db', db); + process.exit(-1); +} + module.exports = { root: rootPath, publicPath: process.env.INSIGHT_PUBLIC_PATH || false, diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index a33bd195..e2db7dcb 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -30,6 +30,8 @@ var Rpc = imports.rpc || require('./Rpc'), async = require('async'), config = require('../config/config'), assert = require('assert'); + + var db = imports.db || levelup(config.leveldb + '/txs',{maxOpenFiles: MAX_OPEN_FILES} ); var Script = require('bitcore/Script'); // This is 0.1.2 = > c++ version of base57-native From 5f3e4db41fe9e5fb6847aca6e97ab6e77bcb1000 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 17 Apr 2014 09:35:57 -0300 Subject: [PATCH 3/5] fix json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d0a130bf..e59faaad 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,8 @@ "moment": "~2.5.0", "sinon": "~1.7.3", "chai": "~1.8.1", - "xmlhttprequest": "~1.6.0" - "bufferput": "git://github.com/bitpay/node-bufferput.git", + "xmlhttprequest": "~1.6.0", + "bufferput": "git://github.com/bitpay/node-bufferput.git" }, "devDependencies": { "grunt": "~0.4.2", From 23b646589ff7a01f2379105a5f78fd8de092caad Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 17 Apr 2014 09:40:30 -0300 Subject: [PATCH 4/5] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e59faaad..8818e462 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "insight-bitcore-api", "description": "An open-source bitcoin blockchain API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.", - "version": "0.1.7", + "version": "0.1.8", "author": { "name": "Ryan X Charles", "email": "ryan@bitpay.com" From 556952352f378e4e588ed36231041d685db5f7d2 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 17 Apr 2014 09:46:19 -0300 Subject: [PATCH 5/5] move db path from /insight-api-db to /.insight --- config/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.js b/config/config.js index f59a8f2f..2d0576d4 100644 --- a/config/config.js +++ b/config/config.js @@ -14,7 +14,7 @@ function getUserHome() { return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; } -var home = process.env.INSIGHT_DB || ( getUserHome() + '/insight-api-db' ); +var home = process.env.INSIGHT_DB || ( getUserHome() + '/.insight' ); if (process.env.INSIGHT_NETWORK === 'livenet') { env = 'livenet';