fix join wallet
This commit is contained in:
parent
8604fe27ca
commit
dcbfb94a34
1 changed files with 17 additions and 7 deletions
|
|
@ -225,11 +225,6 @@ Network.prototype._onMessage = function(enc) {
|
||||||
Network.prototype._setupConnectionHandlers = function(cb) {
|
Network.prototype._setupConnectionHandlers = function(cb) {
|
||||||
preconditions.checkState(this.socket);
|
preconditions.checkState(this.socket);
|
||||||
var self = this;
|
var self = this;
|
||||||
self.socket.on('insight-error', function(m) {
|
|
||||||
console.log('** insgight-error', m);
|
|
||||||
self.emit('serverError');
|
|
||||||
});
|
|
||||||
|
|
||||||
self.socket.on('message', function(m) {
|
self.socket.on('message', function(m) {
|
||||||
// delay execution, to improve error handling
|
// delay execution, to improve error handling
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
@ -239,6 +234,7 @@ Network.prototype._setupConnectionHandlers = function(cb) {
|
||||||
self.socket.on('error', self._onError.bind(self));
|
self.socket.on('error', self._onError.bind(self));
|
||||||
|
|
||||||
self.socket.on('connect', function() {
|
self.socket.on('connect', function() {
|
||||||
|
|
||||||
self.socket.on('disconnect', function() {
|
self.socket.on('disconnect', function() {
|
||||||
self.cleanUp();
|
self.cleanUp();
|
||||||
});
|
});
|
||||||
|
|
@ -304,9 +300,23 @@ Network.prototype.start = function(opts, openCallback) {
|
||||||
this.socket = this.createSocket();
|
this.socket = this.createSocket();
|
||||||
this._setupConnectionHandlers(openCallback);
|
this._setupConnectionHandlers(openCallback);
|
||||||
this.socket.emit('subscribe', pubkey);
|
this.socket.emit('subscribe', pubkey);
|
||||||
this.socket.emit('sync', opts.lastTimestamp);
|
|
||||||
this.started = true;
|
|
||||||
|
|
||||||
|
var self = this,
|
||||||
|
tries = 0;
|
||||||
|
self.socket.on('insight-error', function(m) {
|
||||||
|
|
||||||
|
console.log('Retrying to sync...');
|
||||||
|
setTimeout(function() {
|
||||||
|
if (tries++ > 5) {
|
||||||
|
self.emit('serverError');
|
||||||
|
} else {
|
||||||
|
self.socket.emit('sync', opts.lastTimestamp);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.socket.emit('sync', opts.lastTimestamp);
|
||||||
|
self.started = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.createSocket = function() {
|
Network.prototype.createSocket = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue