Skip to content

Commit 2aefe71

Browse files
committed
fix hash in block historical sync
1 parent 4457342 commit 2aefe71

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

app/models/Block.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ BlockSchema.statics.customCreate = function(block, cb) {
5151
var newBlock = new That();
5252

5353
newBlock.time = block.time ? block.time : Math.round(new Date().getTime() / 1000);
54-
newBlock.hash = block.blockHash;
54+
newBlock.hash = block.hash;
5555

5656
Transaction.createFromArray(block.tx, newBlock.time, function(err, inserted_txs) {
5757
if (err) return cb(err);
58+
5859
newBlock.save(function(err) {
5960
return cb(err, inserted_txs);
6061
});

app/models/Transaction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ TransactionSchema.statics.createFromArray = function(txs, time, next) {
9494

9595
async.forEachLimit(txs, CONCURRENCY, function(txid, cb) {
9696

97-
that.explodeTransactionItems( txid, function(err) {
97+
that.explodeTransactionItems( txid, time, function(err) {
9898
if (err) return next(err);
9999

100100
that.create({txid: txid, time: time}, function(err, new_tx) {

lib/Sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function spec() {
227227
}
228228

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

test/model/transaction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ describe('Transaction', function(){
118118
// Remove first
119119
TransactionItem.remove({txid: v.txid}, function(err) {
120120

121-
Transaction.explodeTransactionItems(v.txid, function(err, tx) {
121+
var now = Math.round(new Date().getTime() / 1000);
122+
Transaction.explodeTransactionItems(v.txid, now, function(err, tx) {
122123
if (err) done(err);
123124

124125
TransactionItem

0 commit comments

Comments
 (0)