Browse Source

set scan status

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

36
lib/server.js

@ -1224,27 +1224,35 @@ WalletService.prototype.scan = function(opts, cb) {
WalletService.prototype.startScan = function(opts, cb) {
var self = this;
function scanFinished(err) {
var data = {};
if (err) {
data.result = 'error';
data.error = err;
} else {
data.result = 'success';
}
self._notify('ScanFinished', data, true);
function scanFinished(wallet, err) {
var result = err ? 'error' : 'success';
var data = {
result: result,
};
if (err) data.error = err;
self.getWallet({}, function(err, wallet) {
wallet.scanStatus = result;
self.storage.storeWallet(wallet, function() {
self._notify('ScanFinished', data, true);
});
});
};
self.getWallet({}, function(err, wallet) {
if (err) return cb(err);
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() {
self.scan(opts, scanFinished);
}, 100);
setTimeout(function() {
self.scan(opts, _.bind(scanFinished, self, wallet));
}, 100);
return cb(null, {
started: true
return cb(null, {
started: true
});
});
});
};

2
test/integration/server.js

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

Loading…
Cancel
Save