better sync for peers

This commit is contained in:
Matias Alejo Garcia 2014-04-20 17:16:21 -03:00
parent a3dffc65ef
commit fe0cccd801
4 changed files with 9 additions and 5 deletions

View File

@ -20,7 +20,6 @@ angular.module('copay.signin').controller('SigninController',
console.log('[signin.js.23:walletId:]',walletId); //TODO console.log('[signin.js.23:walletId:]',walletId); //TODO
var w = walletFactory.open(walletId, opts); var w = walletFactory.open(walletId, opts);
controllerUtils.setupUxHandlers(w); controllerUtils.setupUxHandlers(w);
w.netStart();
}; };
$scope.join = function(secret) { $scope.join = function(secret) {
@ -34,7 +33,6 @@ console.log('[signin.js.23:walletId:]',walletId); //TODO
walletFactory.joinCreateSession(secret, function(w) { walletFactory.joinCreateSession(secret, function(w) {
console.log('[signin.js.33] joinCreateSession RETURN', w); //TODO console.log('[signin.js.33] joinCreateSession RETURN', w); //TODO
controllerUtils.setupUxHandlers(w); controllerUtils.setupUxHandlers(w);
w.setupNetHandlers();
}); });
}; };

View File

@ -32,6 +32,8 @@ PrivateKey.fromObj = function(obj) {
}; };
PrivateKey.prototype.toObj = function() { PrivateKey.prototype.toObj = function() {
console.log('[PrivateKey.js.35] TODO TODO: PRIV: ', this.getExtendedPrivateKeyString()); //TODO
return { return {
extendedPrivateKeyString: this.getExtendedPrivateKeyString(), extendedPrivateKeyString: this.getExtendedPrivateKeyString(),
networkName: this.network.name, networkName: this.network.name,

View File

@ -106,9 +106,11 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
} }
this.log('[Wallet.js.98]' , data.type); //TODO this.log('[Wallet.js.98]' , data.type); //TODO
switch(data.type) { switch(data.type) {
// This handler is repeaded on WalletFactory (#join). TODO
case 'walletId':
this.sendWalletReady(senderId);
break;
case 'walletReady': case 'walletReady':
console.log('[Wallet.js.109] RECV WALLETREADY'); //TODO
this.sendPublicKeyRing(senderId); this.sendPublicKeyRing(senderId);
this.sendTxProposals(senderId); this.sendTxProposals(senderId);
break; break;
@ -189,6 +191,7 @@ console.log('[Wallet.js.177] NET START: emit CREATED'); //TODO
if (otherPeerId !== myPeerId) { if (otherPeerId !== myPeerId) {
net.connectTo(otherPeerId); net.connectTo(otherPeerId);
} }
self.emit('refresh');
} }
}, startOpts); }, startOpts);
}; };

View File

@ -34,7 +34,6 @@ console.log('[controllerUtils.js.30:created:] RECV '); //TODO
$rootScope.wallet.getBalance(function(balance) { $rootScope.wallet.getBalance(function(balance) {
$rootScope.totalBalance = balance; $rootScope.totalBalance = balance;
$rootScope.$digest();
}); });
}); });
w.on('refresh', function() { w.on('refresh', function() {
@ -43,6 +42,8 @@ console.log('[controllerUtils.js.30:created:] RECV '); //TODO
}); });
w.on('openError', root.onErrorDigest); w.on('openError', root.onErrorDigest);
w.on('close', root.onErrorDigest); w.on('close', root.onErrorDigest);
console.log('[controllerUtils.js.45] CALLING NETSTART FROM setupUxHandlers'); //TODO
w.netStart(); w.netStart();
console.log('[controllerUtils.js.45] setupUxHandlers END'); //TODO console.log('[controllerUtils.js.45] setupUxHandlers END'); //TODO
}; };