Browse Source

set scan status

activeAddress
Ivan Socolsky 10 years ago
parent
commit
3678b27bf5
  1. 26
      lib/server.js
  2. 2
      test/integration/server.js

26
lib/server.js

@ -1224,29 +1224,37 @@ WalletService.prototype.scan = function(opts, cb) {
WalletService.prototype.startScan = function(opts, cb) { WalletService.prototype.startScan = function(opts, cb) {
var self = this; var self = this;
function scanFinished(err) { function scanFinished(wallet, err) {
var data = {}; var result = err ? 'error' : 'success';
if (err) { var data = {
data.result = 'error'; result: result,
data.error = err; };
} else { if (err) data.error = err;
data.result = 'success';
} self.getWallet({}, function(err, wallet) {
wallet.scanStatus = result;
self.storage.storeWallet(wallet, function() {
self._notify('ScanFinished', data, true); self._notify('ScanFinished', data, true);
});
});
}; };
self.getWallet({}, function(err, wallet) { self.getWallet({}, function(err, wallet) {
if (err) return cb(err); if (err) return cb(err);
if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete'));
wallet.scanStatus = 'running';
self.storage.storeWallet(wallet, function(err) {
if (err) return cb(err);
setTimeout(function() { setTimeout(function() {
self.scan(opts, scanFinished); self.scan(opts, _.bind(scanFinished, self, wallet));
}, 100); }, 100);
return cb(null, { return cb(null, {
started: true started: true
}); });
}); });
});
}; };

2
test/integration/server.js

@ -2657,7 +2657,7 @@ describe('Wallet service', function() {
NotificationBroadcaster.removeAllListeners(); NotificationBroadcaster.removeAllListeners();
}); });
it.only('should start an asynchronous scan', function(done) { it('should start an asynchronous scan', function(done) {
helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']); helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']);
var expectedPaths = [ var expectedPaths = [
'm/2147483647/0/0', 'm/2147483647/0/0',

Loading…
Cancel
Save