polish reconnect

This commit is contained in:
Manuel Araoz 2014-06-03 11:54:07 -03:00
commit 3934b750f2
2 changed files with 21 additions and 14 deletions

View file

@ -165,6 +165,7 @@ Wallet.prototype._optsToObj = function() {
spendUnconfirmed: this.spendUnconfirmed, spendUnconfirmed: this.spendUnconfirmed,
requiredCopayers: this.requiredCopayers, requiredCopayers: this.requiredCopayers,
totalCopayers: this.totalCopayers, totalCopayers: this.totalCopayers,
reconnectDelay: this.reconnectDelay,
name: this.name, name: this.name,
netKey: this.netKey, netKey: this.netKey,
version: this.version, version: this.version,
@ -258,12 +259,14 @@ Wallet.prototype.netStart = function() {
Wallet.prototype.scheduleConnect = function() { Wallet.prototype.scheduleConnect = function() {
var self = this; var self = this;
if (self.network.isOnline()) {
self.connectToAll(); self.connectToAll();
setTimeout(function() { setTimeout(function() {
self.scheduleConnect(); self.scheduleConnect();
}, },
self.reconnectDelay); self.reconnectDelay);
} }
}
Wallet.prototype.getOnlinePeerIDs = function() { Wallet.prototype.getOnlinePeerIDs = function() {
return this.network.getOnlinePeerIDs(); return this.network.getOnlinePeerIDs();

View file

@ -313,8 +313,8 @@ Network.prototype.setCopayerId = function(copayerId) {
}; };
Network.prototype.peerFromCopayer = function(hex) {
// TODO cache this. // TODO cache this.
Network.prototype.peerFromCopayer = function(hex) {
var SIN = bitcore.SIN; var SIN = bitcore.SIN;
return new SIN(new Buffer(hex,'hex')).toString(); return new SIN(new Buffer(hex,'hex')).toString();
}; };
@ -409,6 +409,10 @@ Network.prototype.send = function(copayerIds, payload, cb) {
}; };
Network.prototype.isOnline = function() {
return !!this.peer;
};
Network.prototype.connectTo = function(copayerId) { Network.prototype.connectTo = function(copayerId) {
var self = this; var self = this;