From 059731eea16a5cb25b6a57a925c4568f1a4c61b9 Mon Sep 17 00:00:00 2001 From: Rob Johnson Date: Thu, 12 Feb 2015 18:46:51 -0600 Subject: [PATCH] Fix for #63 fix for issue #63 In old bitcoind, .dat files seems to be bigger that the actual 128MB, which could cause errors on insight-api --- lib/BlockExtractor.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/BlockExtractor.js b/lib/BlockExtractor.js index 3c69824..91e40b1 100644 --- a/lib/BlockExtractor.js +++ b/lib/BlockExtractor.js @@ -62,10 +62,15 @@ BlockExtractor.prototype.readCurrentFileSync = function() { var stats = fs.statSync(fname); var size = stats.size; - + var mb = parseInt(size/1024/1024); + console.log('Reading Blockfile %s [%d MB]', - fname, parseInt(size/1024/1024)); - + fname, mb); + + if(mb > 1023) + throw new Error('CRITICAL ERROR: file size greater than 1023MB, use cat blk*.dat > bootstrap.dat to create new ' + + 'dat files @128MB. (https://github.com/bitpay/insight-api/issues/35)'); + var fd = fs.openSync(fname, 'r'); var buffer = new Buffer(size);