Skip to content

Commit

Permalink
Handle less than 10 blocks on the main page view. Fixes #6 and #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
gobitfly committed Mar 21, 2017
1 parent a7479cd commit faae73a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ router.get('/', function(req, res, next) {
}, function(lastBlock, callback) {
var blocks = [];

async.times(10, function(n, next) {
var blockCount = 10;

if (lastBlock.number - blockCount < 0) {
blockCount = lastBlock.number + 1;
}

async.times(blockCount, function(n, next) {
web3.eth.getBlock(lastBlock.number - n, true, function(err, block) {
next(err, block);
});
Expand Down

0 comments on commit faae73a

Please sign in to comment.