Browse Source

make ScanFinish a global notification

activeAddress
Ivan Socolsky 10 years ago
parent
commit
47a7f5ef65
  1. 11
      lib/server.js
  2. 1
      test/integration/server.js

11
lib/server.js

@ -253,10 +253,11 @@ WalletService.prototype._emit = function(eventName, args) {
/** /**
* _notify * _notify
* *
* @param type * @param {String} type
* @param data * @param {Object} data
* @param {Boolean} isGlobal - If true, the notification is not issued on behalf of any particular copayer (defaults to false)
*/ */
WalletService.prototype._notify = function(type, data) { WalletService.prototype._notify = function(type, data, isGlobal) {
var self = this; var self = this;
log.debug('Notification', type, data); log.debug('Notification', type, data);
@ -270,7 +271,7 @@ WalletService.prototype._notify = function(type, data) {
type: type, type: type,
data: data, data: data,
ticker: this.notifyTicker++, ticker: this.notifyTicker++,
creatorId: copayerId, creatorId: isGlobal ? null : copayerId,
walletId: walletId, walletId: walletId,
}); });
this.storage.storeNotification(walletId, n, function() { this.storage.storeNotification(walletId, n, function() {
@ -1219,7 +1220,7 @@ WalletService.prototype.startScan = function(opts, cb) {
} else { } else {
data.result = 'success'; data.result = 'success';
} }
self._notify('ScanFinished', data); self._notify('ScanFinished', data, true);
}; };
Utils.runLocked(self.walletId, cb, function(cb) { Utils.runLocked(self.walletId, cb, function(cb) {

1
test/integration/server.js

@ -2867,6 +2867,7 @@ describe('Wallet service', function() {
]; ];
WalletService.onNotification(function(n) { WalletService.onNotification(function(n) {
if (n.type == 'ScanFinished') { if (n.type == 'ScanFinished') {
should.not.exist(n.creatorId);
server.storage.fetchAddresses(wallet.id, function(err, addresses) { server.storage.fetchAddresses(wallet.id, function(err, addresses) {
should.exist(addresses); should.exist(addresses);
addresses.length.should.equal(expectedPaths.length); addresses.length.should.equal(expectedPaths.length);

Loading…
Cancel
Save