diff --git a/lib/bcoin/blockdb.js b/lib/bcoin/blockdb.js index 4181e7ee..ddb0d892 100644 --- a/lib/bcoin/blockdb.js +++ b/lib/bcoin/blockdb.js @@ -522,9 +522,13 @@ BlockDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, opti }); } - // iter.end() here? - if (!key) - return done(); + if (!key) { + return iter.end(function(err) { + if (err) + return done(err); + done(); + }); + } parts = key.split('/'); hash = parts[3]; @@ -656,9 +660,13 @@ BlockDB.prototype.getTXByAddress = function getTXByAddress(addresses, options, c }); } - // iter.end() here? - if (!key) - return done(); + if (!key) { + return iter.end(function(err) { + if (err) + return done(err); + done(); + }); + } hash = key.split('/')[3]; record = self.parseOffset(value); @@ -967,13 +975,17 @@ BlockDB.prototype.getHeight = function getHeight(callback) { if (err) { return iter.end(function() { - return callback(err); + callback(err); }); } - // iter.end() here? - if (!key) - return callback(null, maxHeight); + if (!key) { + return iter.end(function(err) { + if (err) + return callback(err); + callback(null, maxHeight); + }); + } height = +key.split('/')[2]; if (height > maxHeight)