fix hash in block historical sync

This commit is contained in:
Matias Alejo Garcia 2014-01-16 11:01:01 -03:00
parent 4457342af0
commit 2aefe7119d
4 changed files with 6 additions and 4 deletions

View File

@ -51,10 +51,11 @@ BlockSchema.statics.customCreate = function(block, cb) {
var newBlock = new That();
newBlock.time = block.time ? block.time : Math.round(new Date().getTime() / 1000);
newBlock.hash = block.blockHash;
newBlock.hash = block.hash;
Transaction.createFromArray(block.tx, newBlock.time, function(err, inserted_txs) {
if (err) return cb(err);
newBlock.save(function(err) {
return cb(err, inserted_txs);
});

View File

@ -94,7 +94,7 @@ TransactionSchema.statics.createFromArray = function(txs, time, next) {
async.forEachLimit(txs, CONCURRENCY, function(txid, cb) {
that.explodeTransactionItems( txid, function(err) {
that.explodeTransactionItems( txid, time, function(err) {
if (err) return next(err);
that.create({txid: txid, time: time}, function(err, new_tx) {

View File

@ -227,7 +227,7 @@ function spec() {
}
// This will trigger an RPC call
Transaction.explodeTransactionItems( tx.txid, function(err) {
Transaction.explodeTransactionItems( tx.txid, tx.time, function(err) {
if (proc++ % 1000 === 0) progress_bar('\tproc', pull, total);
next(err);
});

View File

@ -118,7 +118,8 @@ describe('Transaction', function(){
// Remove first
TransactionItem.remove({txid: v.txid}, function(err) {
Transaction.explodeTransactionItems(v.txid, function(err, tx) {
var now = Math.round(new Date().getTime() / 1000);
Transaction.explodeTransactionItems(v.txid, now, function(err, tx) {
if (err) done(err);
TransactionItem