From 4f281dcefe3867d0e463f283327f7318b1ff7b12 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Fri, 24 Jul 2015 23:18:14 -0400 Subject: [PATCH] Update chain prevHash cache. --- lib/node.js | 3 +++ test/node.unit.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index ca0160c6..667fc3db 100644 --- a/lib/node.js +++ b/lib/node.js @@ -220,6 +220,9 @@ Node.prototype._syncBitcoind = function() { // Populate height block.__height = self.chain.tip.__height + 1; + // Update chain hashes + self.chain.cache.hashes[block.hash] = block.prevHash; + // Create indexes self.db._onChainAddBlock(block, function(err) { if (err) { diff --git a/test/node.unit.js b/test/node.unit.js index 97cee6e7..33b447d4 100644 --- a/test/node.unit.js +++ b/test/node.unit.js @@ -177,7 +177,10 @@ describe('Bitcoind Node', function() { hash: block.prevHash }, saveMetadata: sinon.stub(), - emit: sinon.stub() + emit: sinon.stub(), + cache: { + hashes: {} + } }; node.db = { _onChainAddBlock: function(block, callback) {