Skip to content

Commit

Permalink
add more logs for debuging roll back issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sqfasd committed Sep 11, 2017
1 parent b2ba26d commit aceac58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,21 +379,23 @@ private.popLastBlock = function (oldLastBlock, callback) {
});
}
}
library.logger.info('begin to pop block ' + oldLastBlock.height + ' ' + oldLastBlock.id);

library.dbLite.query('SAVEPOINT poplastblock');
self.loadBlocksPart({ id: oldLastBlock.previousBlock }, function (err, previousBlock) {
if (err || !previousBlock.length) {
return done(err || 'previousBlock is null');
}
previousBlock = previousBlock[0];

async.eachSeries(oldLastBlock.transactions.reverse(), function (transaction, nextTr) {
var transactions = library.base.block.sortTransactions(oldLastBlock);
async.eachSeries(transactions.reverse(), function (transaction, nextTr) {
async.series([
function (next) {
modules.accounts.getAccount({ publicKey: transaction.senderPublicKey }, function (err, sender) {
if (err) {
return next(err);
}
library.logger.info('undo transacton', JSON.stringify(transaction));
modules.transactions.undo(transaction, oldLastBlock, sender, next);
});
}, function (next) {
Expand Down
1 change: 1 addition & 0 deletions src/core/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private.findUpdate = function (lastBlock, peer, cb) {
}

var unconfirmedTrs = modules.transactions.getUnconfirmedTransactionList(true);
library.logger.info('Undo unconfirmed transactions', unconfirmedTrs)
modules.transactions.undoUnconfirmedList(function (err) {
if (err) {
library.logger.error('Failed to undo uncomfirmed transactions', err);
Expand Down

0 comments on commit aceac58

Please sign in to comment.