From be7e122b0a581001594e6c39e34f965246c543ac Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 9 Jun 2014 19:35:30 -0300 Subject: [PATCH] rm variable reconnect time --- config.js | 36 ++++++++++++++++++------------------ js/models/core/Wallet.js | 4 +--- js/models/network/WebRTC.js | 1 + test/test.Wallet.js | 14 ++------------ 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/config.js b/config.js index 8c0745de5..968a8b108 100644 --- a/config.js +++ b/config.js @@ -42,26 +42,26 @@ var defaultConfig = { config: { 'iceServers': [ // Pass in STUN and TURN servers for maximum network compatibility - { - url: 'stun:162.242.219.26' - }, { - url: 'turn:162.242.219.26', - username: 'bitcore', - credential: 'bitcore', - } // { - // url: 'stun:stun.l.google.com:19302' + // url: 'stun:162.242.219.26' // }, { - // url: 'stun:stun1.l.google.com:19302' - // }, { - // url: 'stun:stun2.l.google.com:19302' - // }, { - // url: 'stun:stun3.l.google.com:19302' - // }, { - // url: 'stun:stun4.l.google.com:19302' - // }, { - // url: 'stun:stunserver.org' + // url: 'turn:162.242.219.26', + // username: 'bitcore', + // credential: 'bitcore', // } + { + url: 'stun:stun.l.google.com:19302' + }, { + url: 'stun:stun1.l.google.com:19302' + }, { + url: 'stun:stun2.l.google.com:19302' + }, { + url: 'stun:stun3.l.google.com:19302' + }, { + url: 'stun:stun4.l.google.com:19302' + }, { + url: 'stun:stunserver.org' + } // // Options fot TURN servers with p2p communications are not possible. // { // url: 'turn:numb.viagenie.ca', @@ -86,7 +86,7 @@ var defaultConfig = { totalCopayers: 3, spendUnconfirmed: 1, verbose: 1, - reconnectDelay: 500, + reconnectDelay: 5000, }, // blockchain service API config diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 15abc65cc..5e5cf12dc 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -164,7 +164,6 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) { Wallet.prototype._handleConnect = function(newCopayerId) { if (newCopayerId) { this.log('#### Setting new COPAYER:', newCopayerId); - this.currentDelay = null; this.sendWalletId(newCopayerId); } var peerID = this.network.peerFromCopayer(newCopayerId) @@ -276,8 +275,7 @@ Wallet.prototype.scheduleConnect = function() { var self = this; if (self.network.isOnline()) { self.connectToAll(); - self.currentDelay = self.currentDelay*2 || self.reconnectDelay; - setTimeout(self.scheduleConnect.bind(self), self.currentDelay); + setTimeout(self.scheduleConnect.bind(self), self.reconnectDelay); } } diff --git a/js/models/network/WebRTC.js b/js/models/network/WebRTC.js index 764acb753..416ba31c8 100644 --- a/js/models/network/WebRTC.js +++ b/js/models/network/WebRTC.js @@ -126,6 +126,7 @@ Network.prototype._onClose = function(peerID) { Network.prototype.connectToCopayers = function(copayerIds) { var self = this; var arrayDiff= Network._arrayDiff(copayerIds, this.connectedCopayers()); +console.log('[WebRTC.js.128:arrayDiff:]',arrayDiff); //TODO arrayDiff.forEach(function(copayerId) { if (this.allowedCopayerIds && !this.allowedCopayerIds[copayerId]) { diff --git a/test/test.Wallet.js b/test/test.Wallet.js index c6f57eb5b..4ea33ab00 100644 --- a/test/test.Wallet.js +++ b/test/test.Wallet.js @@ -238,23 +238,13 @@ describe('Wallet model', function() { throw (); }); - it('call reconnect after interval', function(done) { + it.only('call reconnect after interval', function(done) { var w = createW2(); var testTime = 1000; - var callCount = 0; - var cT = w.reconnectDelay; - var t = 0; - - do { - callCount++; - t += cT; - cT *= 2; - } while (t < testTime); - var spy = sinon.spy(w, 'scheduleConnect'); w.netStart(); setTimeout(function() { - sinon.assert.callCount(spy, callCount); + sinon.assert.callCount(spy, 10); done(); }, testTime); });