progressive reconnect time
This commit is contained in:
parent
be7e122b0a
commit
d0e20c1bff
7 changed files with 37 additions and 18 deletions
|
|
@ -32,7 +32,6 @@ function Wallet(opts) {
|
|||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.name = opts.name;
|
||||
this.netKey = opts.netKey || SecureRandom.getRandomBuffer(8).toString('base64');
|
||||
this.networkName = opts.networkName;
|
||||
|
||||
// Renew token every 24hs
|
||||
if (opts.tokenTime && new Date().getTime() - opts.tokenTime < 86400000) {
|
||||
|
|
@ -93,7 +92,6 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
|
|||
if (hasChanged) {
|
||||
if (wasIncomplete) {
|
||||
this.sendPublicKeyRing();
|
||||
this.connectToAll();
|
||||
}
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
this._lockIncomming();
|
||||
|
|
@ -171,6 +169,7 @@ Wallet.prototype._handleConnect = function(newCopayerId) {
|
|||
};
|
||||
|
||||
Wallet.prototype._handleDisconnect = function(peerID) {
|
||||
this.currentDelay = null;
|
||||
this.emit('disconnect', peerID);
|
||||
};
|
||||
|
||||
|
|
@ -185,7 +184,6 @@ Wallet.prototype._optsToObj = function() {
|
|||
spendUnconfirmed: this.spendUnconfirmed,
|
||||
requiredCopayers: this.requiredCopayers,
|
||||
totalCopayers: this.totalCopayers,
|
||||
reconnectDelay: this.reconnectDelay,
|
||||
name: this.name,
|
||||
netKey: this.netKey,
|
||||
version: this.version,
|
||||
|
|
@ -275,7 +273,8 @@ Wallet.prototype.scheduleConnect = function() {
|
|||
var self = this;
|
||||
if (self.network.isOnline()) {
|
||||
self.connectToAll();
|
||||
setTimeout(self.scheduleConnect.bind(self), self.reconnectDelay);
|
||||
self.currentDelay = self.currentDelay*2 || self.reconnectDelay;
|
||||
setTimeout(self.scheduleConnect.bind(self), self.currentDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue