From e512feef7431963dd04e2bc4ce57b0fc8d553434 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 5 Aug 2023 19:17:20 +0900 Subject: [PATCH] Add debug prints, fix POST request --- backend/src/api/bitcoin/esplora-api.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/api/bitcoin/esplora-api.ts b/backend/src/api/bitcoin/esplora-api.ts index 75d38ea8c..3377ddd52 100644 --- a/backend/src/api/bitcoin/esplora-api.ts +++ b/backend/src/api/bitcoin/esplora-api.ts @@ -105,6 +105,8 @@ class FailoverRouter { this.sortHosts(); + logger.debug(`Tomahawk ranking: ${this.hosts.map(host => '\navg latency ' + Math.round(host.latency).toString().padStart(5, ' ') + ' | reachable? ' + !(host.unreachable || false).toString().padStart(5, ' ') + ' | in sync? ' + !(host.outOfSync || false).toString().padStart(5, ' ') + ` | ${host.host}`).join('')}`); + // switch if the current host is out of sync or significantly slower than the next best alternative if (this.activeHost.outOfSync || this.activeHost.unreachable || (!this.activeHost.preferred && this.activeHost.latency > (this.hosts[0].latency * 2) + 50)) { if (this.activeHost.unreachable) { @@ -196,7 +198,7 @@ class FailoverRouter { } public async $post(path, data: any, responseType = 'json'): Promise { - return this.$query('post', path, null, responseType); + return this.$query('post', path, data, responseType); } }