From 7fe140d78bc1497076464f8b1b39bc015d7787c0 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 20 Feb 2016 01:36:09 -0800 Subject: [PATCH] update cache in blockdb. --- lib/bcoin/blockdb.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/bcoin/blockdb.js b/lib/bcoin/blockdb.js index b62ee87b..07f8f234 100644 --- a/lib/bcoin/blockdb.js +++ b/lib/bcoin/blockdb.js @@ -307,6 +307,9 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) { var hash = tx.hash('hex'); var uniq = {}; + if (self.options.cache) + self.cache.tx.remove(hash); + batch.del('t/t/' + hash); self.fillTX(tx, function(err) { @@ -333,9 +336,6 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) { uaddr = null; } - if (uaddr) - batch.del('t/a/' + uaddr + '/' + hash); - assert(input.output._fileOffset >= 0); coinOffset = self.createOffset( @@ -344,6 +344,9 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) { input.output.height ); + if (uaddr) + batch.del('t/a/' + uaddr + '/' + hash); + if (address) { batch.put('u/a/' + address + '/' + input.prevout.hash @@ -381,6 +384,9 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) { batch.del('u/a/' + address + '/' + hash + '/' + i); batch.del('u/t/' + hash + '/' + i); + + if (self.options.cache) + self.cache.unspent.remove(hash + '/' + i); }); if (!--pending)