|
@ -28,6 +28,23 @@ var Notification = require('./model/notification'); |
|
|
var initialized = false; |
|
|
var initialized = false; |
|
|
var storage, blockExplorer; |
|
|
var storage, blockExplorer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function EventBroadcaster() {}; |
|
|
|
|
|
|
|
|
|
|
|
nodeutil.inherits(EventBroadcaster, events.EventEmitter); |
|
|
|
|
|
|
|
|
|
|
|
EventBroadcaster.prototype.broadcast = function(service, args) { |
|
|
|
|
|
this.emit(service, args); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var _eventBroadcasterInstance; |
|
|
|
|
|
EventBroadcaster.singleton = function() { |
|
|
|
|
|
if (!_eventBroadcasterInstance) { |
|
|
|
|
|
_eventBroadcasterInstance = new EventBroadcaster(); |
|
|
|
|
|
} |
|
|
|
|
|
return _eventBroadcasterInstance; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Creates an instance of the Bitcore Wallet Service. |
|
|
* Creates an instance of the Bitcore Wallet Service. |
|
|
* @constructor |
|
|
* @constructor |
|
@ -41,9 +58,6 @@ function WalletService() { |
|
|
this.notifyTicker = 0; |
|
|
this.notifyTicker = 0; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
nodeutil.inherits(WalletService, events.EventEmitter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Initializes global settings for all instances. |
|
|
* Initializes global settings for all instances. |
|
|
* @param {Object} opts |
|
|
* @param {Object} opts |
|
@ -161,6 +175,9 @@ WalletService.prototype._verifySignature = function(text, signature, pubKey) { |
|
|
return WalletUtils.verifyMessage(text, signature, pubKey); |
|
|
return WalletUtils.verifyMessage(text, signature, pubKey); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
WalletService.prototype._emit = function(args) { |
|
|
|
|
|
EventBroadcaster.singleton().broadcast(this, args); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* _notify |
|
|
* _notify |
|
@ -182,7 +199,7 @@ WalletService.prototype._notify = function(type, data) { |
|
|
ticker: this.notifyTicker++, |
|
|
ticker: this.notifyTicker++, |
|
|
}); |
|
|
}); |
|
|
this.storage.storeNotification(walletId, n, function() { |
|
|
this.storage.storeNotification(walletId, n, function() { |
|
|
self.emit(n); |
|
|
self._emit(n); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|