mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 04:35:49 +00:00
a few formatting changes
This commit is contained in:
committed by
Stefan Thomas
parent
a240efc38d
commit
a23572504b
26
js/remote.js
26
js/remote.js
@@ -23,8 +23,7 @@ var Remote = function (trusted, websocket_ip, websocket_port, trace) {
|
|||||||
this.stand_alone = undefined;
|
this.stand_alone = undefined;
|
||||||
|
|
||||||
// Cache information for accounts.
|
// Cache information for accounts.
|
||||||
this.accounts = {
|
this.account = {};
|
||||||
};
|
|
||||||
|
|
||||||
// Cache for various ledgers.
|
// Cache for various ledgers.
|
||||||
// XXX Clear when ledger advances.
|
// XXX Clear when ledger advances.
|
||||||
@@ -52,14 +51,13 @@ var accounts = {
|
|||||||
// Consider sequence numbers stable if you know you're not generating bad transactions.
|
// Consider sequence numbers stable if you know you're not generating bad transactions.
|
||||||
// Otherwise, clear it to have it automatically refreshed from the network.
|
// Otherwise, clear it to have it automatically refreshed from the network.
|
||||||
|
|
||||||
// acount : { seq : __ }
|
// acount : { seq : __ }
|
||||||
};
|
};
|
||||||
|
|
||||||
Remote.method('connect_helper', function () {
|
Remote.method('connect_helper', function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this.trace)
|
if (this.trace) console.log("remote: connect: %s", this.url);
|
||||||
console.log("remote: connect: %s", this.url);
|
|
||||||
|
|
||||||
this.ws = new WebSocket(this.url);
|
this.ws = new WebSocket(this.url);
|
||||||
|
|
||||||
@@ -68,8 +66,7 @@ Remote.method('connect_helper', function () {
|
|||||||
ws.response = {};
|
ws.response = {};
|
||||||
|
|
||||||
ws.onopen = function () {
|
ws.onopen = function () {
|
||||||
if (this.trace)
|
if (this.trace) console.log("remote: onopen: %s", ws.readyState);
|
||||||
console.log("remote: onopen: %s", ws.readyState);
|
|
||||||
|
|
||||||
ws.onclose = undefined;
|
ws.onclose = undefined;
|
||||||
ws.onerror = undefined;
|
ws.onerror = undefined;
|
||||||
@@ -78,24 +75,17 @@ Remote.method('connect_helper', function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ws.onerror = function () {
|
ws.onerror = function () {
|
||||||
if (this.trace)
|
if (this.trace) console.log("remote: onerror: %s", ws.readyState);
|
||||||
console.log("remote: onerror: %s", ws.readyState);
|
|
||||||
|
|
||||||
ws.onclose = undefined;
|
ws.onclose = undefined;
|
||||||
|
|
||||||
if (self.expire) {
|
if (self.expire) {
|
||||||
if (this.trace)
|
if (this.trace) console.log("remote: was expired");
|
||||||
console.log("remote: was expired");
|
|
||||||
|
|
||||||
self.done(ws.readyState);
|
self.done(ws.readyState);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Delay and retry.
|
// Delay and retry.
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (this.trace)
|
if (this.trace) console.log("remote: retry");
|
||||||
console.log("remote: retry");
|
|
||||||
|
|
||||||
self.connect_helper();
|
self.connect_helper();
|
||||||
}, 50); // Retry rate 50ms.
|
}, 50); // Retry rate 50ms.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user