From fa53bfb3c192e66be2281db0234477aed2e3e2e3 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Fri, 28 Feb 2014 18:54:46 -0200 Subject: [PATCH 1/3] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 82fc3c1d..31259593 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ be downloaded at [Github Insight Repository](https://github.com/bitpay/insight). * **bitcoind** - Download and Install [Bitcoin](http://bitcoin.org/en/download) -*insight* needs a *trusted* bitcoind node to run. *insight* will connect to the node +*insight API* needs a *trusted* bitcoind node to run. *insight API* will connect to the node thru the RPC API, Peer-to-peer protocol and will even read its raw .dat files for syncing. Configure bitcoind to listen to RPC calls and set `txindex` to true. @@ -22,7 +22,7 @@ The easiest way to do this is by copying `./etc/bitcoind/bitcoin.conf` to your bitcoin data directory (usually `"~/.bitcoin"` on Linux, `"%appdata%\Bitcoin\"` on Windows, or `"~/Library/Application Support/Bitcoin"` on Mac OS X). -bitcoind must be running and must have finished downloading the blockchain **before** running *insight*. +bitcoind must be running and must have finished downloading the blockchain **before** running *insight API*. * **Node.js v0.10.x** - Download and Install [Node.js](http://www.nodejs.org/download/). @@ -114,12 +114,12 @@ To run the tests ```$ grunt test``` -Contributions and suggestions are welcomed at [insight github repository](https://github.com/bitpay/insight). +Contributions and suggestions are welcomed at [insight-api github repository](https://github.com/bitpay/insight-api). ## API -By default, insight provides a REST API at /api, but this prefix is configurable from the var `apiPrefix` in the `config.js` file. +By default, insight provides a REST API at `/api`, but this prefix is configurable from the var `apiPrefix` in the `config.js` file. The end-points are: From c14ec5a5b44faa0703330c74674be8824685f10e Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 28 Feb 2014 17:56:07 -0300 Subject: [PATCH 2/3] small fix in address with no txouts --- app/models/Address.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/Address.js b/app/models/Address.js index aef9c255..952d31a7 100644 --- a/app/models/Address.js +++ b/app/models/Address.js @@ -96,11 +96,11 @@ function spec() { async.eachLimit(txOut,CONCURRENCY,function (txItem, a_c) { db.fromIdInfoSimple(txItem.txid, function(err, info) { - var scriptPubKey = self._getScriptPubKey(info.hex, txItem.index); - // we are filtering out even unconfirmed spents! // add || !txItem.spentIsConfirmed - if (!txItem.spentTxId) { + + if (!txItem.spentTxId && info && info.hex) { + var scriptPubKey = self._getScriptPubKey(info.hex, txItem.index); ret.push({ address: self.addrStr, txid: txItem.txid, From ed787d58cbda5e1690a819a1abde416eb514bdac Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 6 Mar 2014 00:01:28 -0300 Subject: [PATCH 3/3] recover from race condition in interrupted sync --- lib/HistoricSync.js | 37 +++++++++++++++++++++++++++---------- lib/TransactionDb.js | 1 - 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/HistoricSync.js b/lib/HistoricSync.js index b87f54a1..75ed2989 100644 --- a/lib/HistoricSync.js +++ b/lib/HistoricSync.js @@ -238,22 +238,32 @@ function spec() { function(err) { if (err) return next(err); var ret = false; - if ( self.blockChainHeight === blockInfo.height || - blockInfo.confirmations > 0) { + if ( self.blockChainHeight === blockInfo.height || // Still the tip + blockInfo.confirmations > 0) { // Or is confirmed ret = false; } else { oldtip = tip; tip = blockInfo.previousblockhash; - assert(tip); - p('Previous TIP is now orphan. Back to:' + tip); - ret = true; + p('Previous TIP is now orphan.'); + if (tip) { + p('\tGoing back to:' + tip); + ret = true; + } + else { + p('\tNo able to recover last tip. A Total resync is needed.'); + tip = self.genesis; + self.needResync = 1; + ret = false; + } } return ret; }, function(err) { self.startBlock = tip; - p('Resuming sync from block:'+tip); + if (!self.needResync) { + p('Resuming sync from block:'+tip); + } return next(err); } ); @@ -354,15 +364,22 @@ function spec() { function(s_c) { self.checkNetworkSettings(s_c); }, - function(s_c) { - self.updateConnectedCountDB(s_c); - }, - function(s_c) { + function(s_c) { self.updateBlockChainHeight(s_c); }, function(s_c) { self.updateStartBlock(s_c); }, + function(s_c) { + if (self.needResync) { + self.needResync=0; + self.sync.destroy(s_c); + } + else s_c(); + }, + function(s_c) { + self.updateConnectedCountDB(s_c); + }, function(s_c) { self.prepareFileSync(opts, s_c); }, diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 03415402..7c7ac978 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -673,7 +673,6 @@ isspent var k = FROM_BLK_PREFIX + hash; var k2 = IN_BLK_PREFIX; - // This is slow, but prevent us to create a new block->tx index. db.createReadStream({ start: k, end: k + '~'