Browse Source

don't try to find blocks with heights less than zero

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
9ecaa79933
  1. 4
      routes/baseActionsRouter.js

4
routes/baseActionsRouter.js

@ -196,13 +196,17 @@ router.get("/blocks", function(req, res) {
var blockHeights = []; var blockHeights = [];
if (sort == "desc") { if (sort == "desc") {
for (var i = (getblockchaininfo.blocks - offset); i > (getblockchaininfo.blocks - offset - limit); i--) { for (var i = (getblockchaininfo.blocks - offset); i > (getblockchaininfo.blocks - offset - limit); i--) {
if (i >= 0) {
blockHeights.push(i); blockHeights.push(i);
} }
}
} else { } else {
for (var i = offset; i < (offset + limit); i++) { for (var i = offset; i < (offset + limit); i++) {
if (i >= 0) {
blockHeights.push(i); blockHeights.push(i);
} }
} }
}
coreApi.getBlocksByHeight(blockHeights).then(function(blocks) { coreApi.getBlocksByHeight(blockHeights).then(function(blocks) {
res.locals.blocks = blocks; res.locals.blocks = blocks;

Loading…
Cancel
Save