From aa6570d23aadab377949dd1f270945ade3403987 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Sat, 7 Oct 2017 14:18:14 -0400 Subject: [PATCH] Fixed issue with missing header on log entry. --- lib/services/block/index.js | 10 ++++++++++ lib/services/header/index.js | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/lib/services/block/index.js b/lib/services/block/index.js index 1e21c71b..305e989f 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -854,11 +854,21 @@ BlockService.prototype._logSynced = function(blockHash) { if (err) { return next(err); } + + if (!header) { + return next(); + } + blockHeight = header.height; next(null, header.prevHash); }); }, function(prevBlockHash, next) { + + if (!prevBlockHash) { + return next(); + } + self._getTimeSinceLastBlock(blockHash, prevBlockHash, function(err, diff) { if (err) { diff --git a/lib/services/header/index.js b/lib/services/header/index.js index 6cc97d5c..a68aeae4 100644 --- a/lib/services/header/index.js +++ b/lib/services/header/index.js @@ -590,6 +590,10 @@ HeaderService.prototype._getHeader = function(height, hash, callback) { return callback(new Error('invalid arguments')); } + if (height === self._lastHeader.height || hash === self._lastHeader.hash) { + return callback(null, self._lastHeader); + } + var key; if (hash) { key = self._encoding.encodeHeaderHashKey(hash);