@bithomp/xrpl-api 3.7.23 → 3.7.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/connection.js
CHANGED
|
@@ -52,7 +52,7 @@ exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
|
|
|
52
52
|
const SLOW_DOWN_ERROR_MESSAGES = [
|
|
53
53
|
"slowDown",
|
|
54
54
|
"Unexpected server response: 429",
|
|
55
|
-
"You are placing too much load on the server."
|
|
55
|
+
"You are placing too much load on the server.",
|
|
56
56
|
];
|
|
57
57
|
class Connection extends events_1.EventEmitter {
|
|
58
58
|
constructor(url, type, options = {}) {
|
|
@@ -103,15 +103,20 @@ class Connection extends events_1.EventEmitter {
|
|
|
103
103
|
this.connectionValidation("connect");
|
|
104
104
|
}
|
|
105
105
|
catch (err) {
|
|
106
|
+
const errorMessage = err?.message || err?.name || err;
|
|
106
107
|
this.logger?.warn({
|
|
107
108
|
service: "Bithomp::XRPL::Connection",
|
|
108
109
|
function: "connect",
|
|
109
110
|
url: this.url,
|
|
110
|
-
error:
|
|
111
|
+
error: errorMessage,
|
|
111
112
|
});
|
|
112
113
|
this.removeWatchTimer();
|
|
113
114
|
this.removeClient();
|
|
114
|
-
|
|
115
|
+
let reconnectDelay = LEDGER_CLOSED_TIMEOUT;
|
|
116
|
+
if (SLOW_DOWN_ERROR_MESSAGES.includes(errorMessage)) {
|
|
117
|
+
reconnectDelay = LEDGER_CLOSED_TIMEOUT * 5;
|
|
118
|
+
}
|
|
119
|
+
this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, reconnectDelay);
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
async disconnect() {
|
|
@@ -260,18 +260,19 @@ function adjustBalancesForPaymentChannel(balanceChanges, metadata, nativeCurrenc
|
|
|
260
260
|
else {
|
|
261
261
|
unlockedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(channelChanges?.balance?.value || "0");
|
|
262
262
|
}
|
|
263
|
-
if (unlockedAmount.isZero()) {
|
|
264
|
-
|
|
263
|
+
if (!unlockedAmount.isZero()) {
|
|
264
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
265
|
+
{ currency: channelChanges.amount.currency, value: `-${unlockedAmount.toString()}` },
|
|
266
|
+
]);
|
|
265
267
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
]);
|
|
268
|
+
if (channelChanges.balanceChange) {
|
|
269
|
+
if (channelChanges.source.address !== tx.Account && channelChanges?.balance && channelChanges?.amount) {
|
|
270
|
+
const returnedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(new bignumber_js_1.default(channelChanges.balance.value));
|
|
271
|
+
if (!returnedAmount.isZero()) {
|
|
272
|
+
adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
|
|
273
|
+
{ currency: channelChanges.amount.currency, value: `-${returnedAmount.toString()}` },
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
}
|