update cache in blockdb.

This commit is contained in:
Christopher Jeffrey 2016-02-20 01:36:09 -08:00
parent f2e546c3bd
commit 7fe140d78b

View File

@ -307,6 +307,9 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) {
var hash = tx.hash('hex'); var hash = tx.hash('hex');
var uniq = {}; var uniq = {};
if (self.options.cache)
self.cache.tx.remove(hash);
batch.del('t/t/' + hash); batch.del('t/t/' + hash);
self.fillTX(tx, function(err) { self.fillTX(tx, function(err) {
@ -333,9 +336,6 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) {
uaddr = null; uaddr = null;
} }
if (uaddr)
batch.del('t/a/' + uaddr + '/' + hash);
assert(input.output._fileOffset >= 0); assert(input.output._fileOffset >= 0);
coinOffset = self.createOffset( coinOffset = self.createOffset(
@ -344,6 +344,9 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) {
input.output.height input.output.height
); );
if (uaddr)
batch.del('t/a/' + uaddr + '/' + hash);
if (address) { if (address) {
batch.put('u/a/' + address batch.put('u/a/' + address
+ '/' + input.prevout.hash + '/' + input.prevout.hash
@ -381,6 +384,9 @@ BlockDB.prototype.removeBlock = function removeBlock(hash, callback) {
batch.del('u/a/' + address + '/' + hash + '/' + i); batch.del('u/a/' + address + '/' + hash + '/' + i);
batch.del('u/t/' + hash + '/' + i); batch.del('u/t/' + hash + '/' + i);
if (self.options.cache)
self.cache.unspent.remove(hash + '/' + i);
}); });
if (!--pending) if (!--pending)