Fixed for getDetailedTransaction.
This commit is contained in:
parent
2a1af1e93f
commit
0c75879084
@ -368,7 +368,8 @@ BlockService.prototype._queueBlock = function(block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info('Block Service: The best block hash is: ' + self._tip.hash +
|
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();
|
self._timeOfLastBlockReport = Date.now();
|
||||||
|
|
||||||
log.debug('Block Service: completed processing block: ' + block.rhash() +
|
log.debug('Block Service: completed processing block: ' + block.rhash() +
|
||||||
@ -638,7 +639,7 @@ BlockService.prototype._processBlock = function(block, callback) {
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug('Block Service: new block: ' + block.rhash());
|
log.info('Block Service: new block: ' + block.rhash());
|
||||||
|
|
||||||
// common case
|
// common case
|
||||||
if (!self._detectReorg(block)) {
|
if (!self._detectReorg(block)) {
|
||||||
|
|||||||
@ -260,7 +260,7 @@ HeaderService.prototype._queueBlock = function(block) {
|
|||||||
return self._handleError(err);
|
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);
|
var dbOps = self._getDBOpForLastHeader(header);
|
||||||
dbOps = dbOps.concat(self._onHeader(header));
|
dbOps = dbOps.concat(self._onHeader(header));
|
||||||
|
console.log(dbOps);
|
||||||
self._saveHeaders(dbOps, callback);
|
self._saveHeaders(dbOps, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -591,6 +592,7 @@ HeaderService.prototype._detectReorg = function(block, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.getBlockHeader(prevHash, function(err, header) {
|
self.getBlockHeader(prevHash, function(err, header) {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
@ -599,7 +601,8 @@ HeaderService.prototype._detectReorg = function(block, callback) {
|
|||||||
return callback(null, header);
|
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.');
|
' as its previous block, yet we have not stored this block in our data set, thus ignoring this block.');
|
||||||
callback(null, false);
|
callback(null, false);
|
||||||
|
|
||||||
|
|||||||
@ -37,37 +37,8 @@ TransactionService.prototype.getAPIMethods = function() {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
TransactionService.prototype.getDetailedTransaction = function(txid, options, callback) {
|
TransactionService.prototype.getDetailedTransaction =
|
||||||
var self = this;
|
TransactionService.prototype.getTransaction = function(txid, options, callback) {
|
||||||
|
|
||||||
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) {
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -93,8 +64,7 @@ TransactionService.prototype._getSupplementaryTransactionInfo = function(txid, t
|
|||||||
var self = this;
|
var self = this;
|
||||||
tx.confirmations = self._block.getTip().height - tx.__height + 1;
|
tx.confirmations = self._block.getTip().height - tx.__height + 1;
|
||||||
|
|
||||||
// TODO maybe we should index the block hash along with the height on tx,
|
// TODO maybe we should index the block hash along with the height on tx
|
||||||
// so that this extra lookup isn't necessary
|
|
||||||
self._header.getBlockHeader(tx.__height, function(err, header) {
|
self._header.getBlockHeader(tx.__height, function(err, header) {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -102,7 +72,9 @@ TransactionService.prototype._getSupplementaryTransactionInfo = function(txid, t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (header) {
|
if (header) {
|
||||||
|
// Do we need both of these?
|
||||||
tx.blockHash = header.hash;
|
tx.blockHash = header.hash;
|
||||||
|
tx.__blockHash = header.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, txid, tx, options);
|
callback(null, txid, tx, options);
|
||||||
@ -177,6 +149,7 @@ TransactionService.prototype._getMempoolTransaction = function(txid, tx, options
|
|||||||
tx.__inputValues = inputValues;
|
tx.__inputValues = inputValues;
|
||||||
tx.confirmations = 0;
|
tx.confirmations = 0;
|
||||||
tx.blockHash = null;
|
tx.blockHash = null;
|
||||||
|
tx.__blockHash = null;
|
||||||
callback(null, tx, options);
|
callback(null, tx, options);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user