Skip to content

Commit

Permalink
Use last block time for moreTs
Browse files Browse the repository at this point in the history
  • Loading branch information
Braydon Fuller committed Jul 25, 2016
1 parent 95bcad8 commit e650561
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,10 @@ BlockController.prototype.blockIndex = function(req, res) {
});
};

BlockController.prototype._getBlockSummary = function(hash, moreTimestamp, next) {
BlockController.prototype._getBlockSummary = function(hash, next) {
var self = this;

function finish(result) {
if (moreTimestamp > result.time) {
moreTimestamp = result.time;
}
return next(null, result);
}

Expand Down Expand Up @@ -257,7 +254,6 @@ BlockController.prototype.list = function(req, res) {
var next = lte ? this.formatTimestamp(new Date(lte * 1000)) : null;
var limit = parseInt(req.query.limit || BLOCK_LIMIT);
var more = false;
var moreTimestamp = lte;

self.node.services.bitcoind.getBlockHashesByTimestamp(lte, gte, function(err, hashes) {
if(err) {
Expand All @@ -274,7 +270,7 @@ BlockController.prototype.list = function(req, res) {
async.mapSeries(
hashes,
function(hash, next) {
self._getBlockSummary(hash, moreTimestamp, next);
self._getBlockSummary(hash, next);
},
function(err, blocks) {
if(err) {
Expand All @@ -299,7 +295,7 @@ BlockController.prototype.list = function(req, res) {
};

if(more) {
data.pagination.moreTs = moreTimestamp;
data.pagination.moreTs = blocks[blocks.length - 1].time;
}

res.jsonp(data);
Expand Down

0 comments on commit e650561

Please sign in to comment.