Skip to content

Commit 1a404d4

Browse files
committed
Merge pull request #58 from matiu/bug/fix-jshint
fix jslint
2 parents 8f9fdc1 + 751d6ce commit 1a404d4

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

app/models/Block.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ var mongoose = require('mongoose'),
99
util = require('bitcore/util/util'),
1010
BitcoreBlock= require('bitcore/Block').class(),
1111
Transaction = require('./Transaction'),
12-
async = require('async'),
1312
config = require('../../config/config')
1413
;
1514

16-
var CONCURRENCY = 5;
17-
1815
/**
1916
* Block Schema
2017
*/
@@ -47,16 +44,18 @@ BlockSchema.path('title').validate(function(title) {
4744

4845
BlockSchema.statics.createTimestamped = function(block, cb) {
4946

50-
var that = this;
47+
var That= this;
5148
var now = Math.round(new Date().getTime() / 1000);
5249

5350
var BlockSchema = mongoose.model('Block', BlockSchema);
54-
var newBlock = new that();
51+
var newBlock = new That();
5552
newBlock.time = now;
5653

5754
Transaction.createFromArray(block.tx, function(err, inserted_txs) {
5855
if (err) return cb(err);
59-
newBlock.save(cb);
56+
newBlock.save(function(err) {
57+
return cb(err, inserted_txs);
58+
});
6059
});
6160
};
6261

app/models/Transaction.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,15 @@ TransactionSchema.statics.createFromArray = function(txs, next) {
9696
async.forEachLimit(txs, CONCURRENCY, function(txid, cb) {
9797

9898
that.explodeTransactionItems( txid, function(err) {
99+
if (err) return next(err);
99100

100101
that.create({txid: txid, time: now}, function(err, new_tx) {
101-
102-
//console.log("created:", err, new_tx);
103-
104102
if (err && ! err.toString().match(/E11000/)) return cb(err);
105103

106104
if (new_tx) mongo_txs.push(new_tx);
107105
return cb();
108106
});
109-
})
107+
});
110108
},
111109
function(err) {
112110
return next(err, mongo_txs);
@@ -117,8 +115,6 @@ TransactionSchema.statics.createFromArray = function(txs, next) {
117115
TransactionSchema.statics.explodeTransactionItems = function(txid, cb) {
118116

119117
this.queryInfo(txid, function(err, info) {
120-
121-
//console.log("INFO",info);
122118
if (err || !info) return cb(err);
123119

124120
var index = 0;
@@ -168,7 +164,8 @@ TransactionSchema.statics.explodeTransactionItems = function(txid, cb) {
168164
}
169165
},
170166
function (err) {
171-
return cb(err);
167+
if (err && ! err.toString().match(/E11000/)) return cb(err);
168+
return cb();
172169
});
173170
});
174171
});

lib/Sync.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function spec() {
4545
function(c) {
4646
Block.findOne({hash:blockHash}, function(err,block){
4747
if (err) { console.log(err); return c(err); };
48-
4948
if (block) {
5049
existed = 1;
5150
blockObj = block;

0 commit comments

Comments
 (0)