diff --git a/lib/services/block/index.js b/lib/services/block/index.js index f2579326..5648d902 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -368,7 +368,8 @@ BlockService.prototype._queueBlock = function(block) { } log.info('Block Service: The best block hash is: ' + self._tip.hash + - ' at height: ' + self._tip.height + ' Time since last block: ' + utils.convertMillisecondsToHumanReadable(Date.now() - self._timeOfLastBlockReport)); + ' at height: ' + self._tip.height + ' Time since last block: ' + + utils.convertMillisecondsToHumanReadable(Date.now() - self._timeOfLastBlockReport)); self._timeOfLastBlockReport = Date.now(); log.debug('Block Service: completed processing block: ' + block.rhash() + @@ -638,7 +639,7 @@ BlockService.prototype._processBlock = function(block, callback) { return callback(); } - log.debug('Block Service: new block: ' + block.rhash()); + log.info('Block Service: new block: ' + block.rhash()); // common case if (!self._detectReorg(block)) { diff --git a/lib/services/header/index.js b/lib/services/header/index.js index 3bf2f8f3..ee36840b 100644 --- a/lib/services/header/index.js +++ b/lib/services/header/index.js @@ -260,7 +260,7 @@ HeaderService.prototype._queueBlock = function(block) { return self._handleError(err); } - log.debug('Header Service: completed processing block: ' + block.rhash() + ' prev hash: ' + bcoin.util.revHex(block.prevBlock)); + log.info('Header Service: completed processing block: ' + block.rhash() + ' prev hash: ' + bcoin.util.revHex(block.prevBlock)); }); @@ -335,6 +335,7 @@ HeaderService.prototype._syncBlock = function(block, callback) { var dbOps = self._getDBOpForLastHeader(header); dbOps = dbOps.concat(self._onHeader(header)); + console.log(dbOps); self._saveHeaders(dbOps, callback); }; @@ -591,6 +592,7 @@ HeaderService.prototype._detectReorg = function(block, callback) { } self.getBlockHeader(prevHash, function(err, header) { + if (err) { return callback(err); } @@ -599,7 +601,8 @@ HeaderService.prototype._detectReorg = function(block, callback) { return callback(null, header); } - log.warn('Block: ' + block.rhash() + ' references: ' + prevHash + + // this should be very rare + log.warn('Header Service: Block: ' + block.rhash() + ' references: ' + prevHash + ' as its previous block, yet we have not stored this block in our data set, thus ignoring this block.'); callback(null, false); diff --git a/lib/services/transaction/index.js b/lib/services/transaction/index.js index 5e64fb8c..5e92676d 100644 --- a/lib/services/transaction/index.js +++ b/lib/services/transaction/index.js @@ -37,37 +37,8 @@ TransactionService.prototype.getAPIMethods = function() { ]; }; -TransactionService.prototype.getDetailedTransaction = function(txid, options, callback) { - var self = this; - - this.getTransaction(txid, options, function(err, tx) { - - if (err) { - return callback(err); - } - - if (!tx) { - return callback(); - } - - self._header.getBlockHeader(tx.__height, function(err, header) { - - if (err) { - return callback(err); - } - - assert(header, 'Tx must have a header entry in header db for given height.'); - - tx.__blockhash = header.hash; - - callback(null, tx); - - }); - - }); -}; - -TransactionService.prototype.getTransaction = function(txid, options, callback) { +TransactionService.prototype.getDetailedTransaction = + TransactionService.prototype.getTransaction = function(txid, options, callback) { var self = this; @@ -93,8 +64,7 @@ TransactionService.prototype._getSupplementaryTransactionInfo = function(txid, t var self = this; tx.confirmations = self._block.getTip().height - tx.__height + 1; - // TODO maybe we should index the block hash along with the height on tx, - // so that this extra lookup isn't necessary + // TODO maybe we should index the block hash along with the height on tx self._header.getBlockHeader(tx.__height, function(err, header) { if (err) { @@ -102,7 +72,9 @@ TransactionService.prototype._getSupplementaryTransactionInfo = function(txid, t } if (header) { + // Do we need both of these? tx.blockHash = header.hash; + tx.__blockHash = header.hash; } callback(null, txid, tx, options); @@ -177,6 +149,7 @@ TransactionService.prototype._getMempoolTransaction = function(txid, tx, options tx.__inputValues = inputValues; tx.confirmations = 0; tx.blockHash = null; + tx.__blockHash = null; callback(null, tx, options); });