walletdb: lock during rescan.
This commit is contained in:
parent
aec3548b26
commit
52f00c8fe2
@ -1372,9 +1372,6 @@ ChainDB.prototype.scan = function scan(start, filter, iter, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txs.length === 0)
|
|
||||||
return self.getNextHash(entry.hash, next);
|
|
||||||
|
|
||||||
iter(entry, txs, function(err) {
|
iter(entry, txs, function(err) {
|
||||||
if (err)
|
if (err)
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|||||||
@ -1135,7 +1135,12 @@ WalletDB.prototype.rescan = function rescan(chaindb, height, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (height == null)
|
if (height == null)
|
||||||
height = self.height;
|
height = this.height;
|
||||||
|
|
||||||
|
callback = this._lockTX(rescan, [chaindb, height, callback]);
|
||||||
|
|
||||||
|
if (!callback)
|
||||||
|
return;
|
||||||
|
|
||||||
this.getAddressHashes(function(err, hashes) {
|
this.getAddressHashes(function(err, hashes) {
|
||||||
if (err)
|
if (err)
|
||||||
@ -1144,7 +1149,7 @@ WalletDB.prototype.rescan = function rescan(chaindb, height, callback) {
|
|||||||
self.logger.info('Scanning for %d addresses.', hashes.length);
|
self.logger.info('Scanning for %d addresses.', hashes.length);
|
||||||
|
|
||||||
chaindb.scan(height, hashes, function(block, txs, next) {
|
chaindb.scan(height, hashes, function(block, txs, next) {
|
||||||
self.addBlock(block, txs, next);
|
self.addBlock(block, txs, next, true);
|
||||||
}, callback);
|
}, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1395,11 +1400,11 @@ WalletDB.prototype.getWalletsByTX = function getWalletsByTX(hash, callback) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WalletDB.prototype.addBlock = function addBlock(entry, txs, callback) {
|
WalletDB.prototype.addBlock = function addBlock(entry, txs, callback, force) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var block, matches, hash;
|
var block, matches, hash;
|
||||||
|
|
||||||
callback = this._lockTX(addBlock, [entry, txs, callback]);
|
callback = this._lockTX(addBlock, [entry, txs, callback], force);
|
||||||
|
|
||||||
if (!callback)
|
if (!callback)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user