From 751d6ce707d3f195f520793964ed1e0e934fb04f Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 15 Jan 2014 18:11:18 -0300 Subject: [PATCH] fix jslint --- app/models/Block.js | 11 +++++------ app/models/Transaction.js | 11 ++++------- lib/Sync.js | 1 - 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/models/Block.js b/app/models/Block.js index 1506422..f3603ef 100644 --- a/app/models/Block.js +++ b/app/models/Block.js @@ -9,12 +9,9 @@ var mongoose = require('mongoose'), util = require('bitcore/util/util'), BitcoreBlock= require('bitcore/Block').class(), Transaction = require('./Transaction'), - async = require('async'), config = require('../../config/config') ; -var CONCURRENCY = 5; - /** * Block Schema */ @@ -47,16 +44,18 @@ BlockSchema.path('title').validate(function(title) { BlockSchema.statics.createTimestamped = function(block, cb) { - var that = this; + var That= this; var now = Math.round(new Date().getTime() / 1000); var BlockSchema = mongoose.model('Block', BlockSchema); - var newBlock = new that(); + var newBlock = new That(); newBlock.time = now; Transaction.createFromArray(block.tx, function(err, inserted_txs) { if (err) return cb(err); - newBlock.save(cb); + newBlock.save(function(err) { + return cb(err, inserted_txs); + }); }); }; diff --git a/app/models/Transaction.js b/app/models/Transaction.js index 79b309c..80287f5 100644 --- a/app/models/Transaction.js +++ b/app/models/Transaction.js @@ -96,17 +96,15 @@ TransactionSchema.statics.createFromArray = function(txs, next) { async.forEachLimit(txs, CONCURRENCY, function(txid, cb) { that.explodeTransactionItems( txid, function(err) { + if (err) return next(err); that.create({txid: txid, time: now}, function(err, new_tx) { - - //console.log("created:", err, new_tx); - if (err && ! err.toString().match(/E11000/)) return cb(err); if (new_tx) mongo_txs.push(new_tx); return cb(); }); - }) + }); }, function(err) { return next(err, mongo_txs); @@ -117,8 +115,6 @@ TransactionSchema.statics.createFromArray = function(txs, next) { TransactionSchema.statics.explodeTransactionItems = function(txid, cb) { this.queryInfo(txid, function(err, info) { - - //console.log("INFO",info); if (err || !info) return cb(err); var index = 0; @@ -168,7 +164,8 @@ TransactionSchema.statics.explodeTransactionItems = function(txid, cb) { } }, function (err) { - return cb(err); + if (err && ! err.toString().match(/E11000/)) return cb(err); + return cb(); }); }); }); diff --git a/lib/Sync.js b/lib/Sync.js index ecfd85f..6393934 100644 --- a/lib/Sync.js +++ b/lib/Sync.js @@ -45,7 +45,6 @@ function spec() { function(c) { Block.findOne({hash:blockHash}, function(err,block){ if (err) { console.log(err); return c(err); }; - if (block) { existed = 1; blockObj = block;