|
|
@ -1143,8 +1143,6 @@ WalletService.prototype.scan = function(opts, cb) { |
|
|
|
|
|
|
|
opts = opts || {}; |
|
|
|
|
|
|
|
var allAddresses = []; |
|
|
|
|
|
|
|
function deriveAddresses(size, derivator, cb) { |
|
|
|
async.mapSeries(_.range(size), function(i, next) { |
|
|
|
setTimeout(function() { |
|
|
@ -1160,6 +1158,7 @@ WalletService.prototype.scan = function(opts, cb) { |
|
|
|
|
|
|
|
function scanBranch(derivator, cb) { |
|
|
|
var activity = true; |
|
|
|
var allAddresses = []; |
|
|
|
async.whilst(function() { |
|
|
|
return activity; |
|
|
|
}, function(next) { |
|
|
@ -1172,7 +1171,9 @@ WalletService.prototype.scan = function(opts, cb) { |
|
|
|
next(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, cb); |
|
|
|
}, function(err) { |
|
|
|
return cb(err, _.flatten(allAddresses)); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -1193,13 +1194,11 @@ WalletService.prototype.scan = function(opts, cb) { |
|
|
|
}); |
|
|
|
|
|
|
|
async.eachSeries(derivators, function(derivator, next) { |
|
|
|
scanBranch(derivator, next); |
|
|
|
}, function(err) { |
|
|
|
if (err) return cb(err); |
|
|
|
self.storage.storeAddressAndWallet(wallet, _.flatten(allAddresses), function(err) { |
|
|
|
return cb(err); |
|
|
|
scanBranch(derivator, function(err, addresses) { |
|
|
|
if (err) return next(err); |
|
|
|
self.storage.storeAddressAndWallet(wallet, addresses, next); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, cb); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|