enhacements on notifications and balance updates
This commit is contained in:
parent
a3d0b9e48b
commit
95e8a22c54
7 changed files with 73 additions and 74 deletions
|
|
@ -294,13 +294,11 @@ Network.prototype.greet = function(copayerId, secretNumber) {
|
|||
};
|
||||
|
||||
Network.prototype._addCopayerMap = function(peerId, copayerId) {
|
||||
console.log('[Async.js.296:_addCopayerMap:]',peerId, copayerId); //TODO
|
||||
if (!this.copayerForPeer[peerId]) {
|
||||
if (Object.keys(this.copayerForPeer).length < this.maxPeers) {
|
||||
this.copayerForPeer[peerId] = copayerId;
|
||||
}
|
||||
}
|
||||
console.log('[Async.js.296:_addCopayerMap:]',this.copayerForPeer); //TODO
|
||||
};
|
||||
|
||||
Network.prototype._setInboundPeerAuth = function(peerId) {
|
||||
|
|
@ -376,7 +374,6 @@ Network.prototype.send = function(dest, payload, cb) {
|
|||
dest = this.getCopayerIds();
|
||||
payload.isBroadcast = 1;
|
||||
}
|
||||
console.log('[Async.js.374:dest:]',dest); //TODO
|
||||
|
||||
if (typeof dest === 'string')
|
||||
dest = [dest];
|
||||
|
|
|
|||
|
|
@ -200,9 +200,10 @@ Identity.open = function(email, password, opts, cb) {
|
|||
var firstWallet;
|
||||
_.each(wids, function(wid) {
|
||||
iden.openWallet(wid, function(err, w) {
|
||||
if (err)
|
||||
if (err) {
|
||||
log.error('Cound not open wallet id:' + wid + '. Skipping')
|
||||
else {
|
||||
iden.profile.deleteWallet(wid, function() {});
|
||||
} else {
|
||||
log.info('Open wallet id:' + wid + ' opened');
|
||||
if (!firstWallet)
|
||||
firstWallet = w;
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ Insight.prototype.subscribe = function(addresses) {
|
|||
|
||||
s.emit('subscribe', address);
|
||||
s.on(address, handler);
|
||||
} else {
|
||||
log.debug('Already subcribed to: ', address);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@ Wallet.prototype.seedCopayer = function(pubKey) {
|
|||
Wallet.prototype._newAddresses = function(dontUpdateUx) {
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
this.subscribeToAddresses();
|
||||
|
||||
};
|
||||
this.emit('newAddresses', dontUpdateUx);
|
||||
};
|
||||
|
|
@ -380,7 +381,6 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
|||
|
||||
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
||||
var wasIncomplete = !this.publicKeyRing.isComplete();
|
||||
console.log('[Wallet.js.382:wasIncomplete:]',wasIncomplete); //TODO
|
||||
var hasChanged;
|
||||
|
||||
try {
|
||||
|
|
@ -390,7 +390,6 @@ console.log('[Wallet.js.382:wasIncomplete:]',wasIncomplete); //TODO
|
|||
this.emit('connectionError', e.message);
|
||||
return;
|
||||
}
|
||||
console.log('[Wallet.js.393:hasChanged:]',hasChanged); //TODO
|
||||
if (hasChanged) {
|
||||
if (wasIncomplete) {
|
||||
this.sendPublicKeyRing();
|
||||
|
|
@ -881,12 +880,11 @@ Wallet.prototype._setBlockchainListeners = function() {
|
|||
var self = this;
|
||||
self.blockchain.removeAllListeners();
|
||||
|
||||
|
||||
log.debug('Setting Blockchain listeners for', this.getId());
|
||||
self.blockchain.on('reconnect', function(attempts) {
|
||||
log.debug('Wallet:' + self.id + 'blockchain reconnect event');
|
||||
self.emit('insightReconnected');
|
||||
|
||||
// Subscription should persist? TODO
|
||||
//self.subscribeToAddresses();
|
||||
});
|
||||
|
||||
self.blockchain.on('disconnect', function() {
|
||||
|
|
@ -894,7 +892,7 @@ Wallet.prototype._setBlockchainListeners = function() {
|
|||
self.emit('insightError');
|
||||
});
|
||||
self.blockchain.on('tx', function(tx) {
|
||||
log.debug('Wallet:' + self.id + 'blockchain tx event');
|
||||
log.debug('Wallet:' + self.id + ' blockchain tx event');
|
||||
var addresses = self.getAddressesInfo();
|
||||
var addr = _.findWhere(addresses, {
|
||||
addressStr: tx.address
|
||||
|
|
@ -1305,7 +1303,7 @@ Wallet.prototype.sendIndexes = function(recipients) {
|
|||
* @param {string[]} recipients - the pubkeys of the recipients
|
||||
*/
|
||||
Wallet.prototype.sendAddressBook = function(recipients) {
|
||||
if ( !Object.keys(this.addressBook).length ) return;
|
||||
if (!Object.keys(this.addressBook).length) return;
|
||||
log.debug('Wallet:' + this.id + ' ### SENDING addressBook TO:', recipients || 'All', this.addressBook);
|
||||
this.send(recipients, {
|
||||
type: 'addressbook',
|
||||
|
|
@ -2221,6 +2219,7 @@ Wallet.prototype.getAddressesStr = function(opts) {
|
|||
Wallet.prototype.subscribeToAddresses = function() {
|
||||
var addrInfo = this.publicKeyRing.getAddressesInfo();
|
||||
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));
|
||||
log.debug('Subscribed to ' + addrInfo.length + ' addresses'); //TODO
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue