improve getBlock.
This commit is contained in:
parent
cbed3bbc4f
commit
e10c3d2547
@ -858,6 +858,9 @@ BlockDB.prototype.getBlock = function getBlock(hash, callback) {
|
|||||||
}
|
}
|
||||||
block._fileOffset = record.offset;
|
block._fileOffset = record.offset;
|
||||||
block.height = record.height;
|
block.height = record.height;
|
||||||
|
block.txs.forEach(function(tx) {
|
||||||
|
tx.height = block.height;
|
||||||
|
});
|
||||||
if (self.options.paranoid) {
|
if (self.options.paranoid) {
|
||||||
if (typeof hash === 'number') {
|
if (typeof hash === 'number') {
|
||||||
self._getEntry(hash, function(err, entry) {
|
self._getEntry(hash, function(err, entry) {
|
||||||
|
|||||||
@ -133,7 +133,12 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
|
|
||||||
// Block by hash/height
|
// Block by hash/height
|
||||||
this.get('/block/:hash', function(req, res, next, send) {
|
this.get('/block/:hash', function(req, res, next, send) {
|
||||||
self.node.getBlock(req.params.hash, function(err, block) {
|
var hash = req.params.hash;
|
||||||
|
|
||||||
|
if (utils.isInt(hash))
|
||||||
|
hash = +hash;
|
||||||
|
|
||||||
|
self.node.getBlock(hash, function(err, block) {
|
||||||
if (err)
|
if (err)
|
||||||
return next(err);
|
return next(err);
|
||||||
if (!block)
|
if (!block)
|
||||||
|
|||||||
@ -139,6 +139,21 @@ Node.prototype._init = function _init() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Node.prototype.getBlock = function getBlock(hash, callback) {
|
||||||
|
var self = this;
|
||||||
|
var coin;
|
||||||
|
|
||||||
|
this.blockdb.getBlock(hash, function(err, block) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
|
||||||
|
if (!block)
|
||||||
|
return callback();
|
||||||
|
|
||||||
|
return callback(null, block);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Node.prototype.getCoin = function getCoin(hash, index, callback) {
|
Node.prototype.getCoin = function getCoin(hash, index, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var coin;
|
var coin;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user