*If we have no active gateways, try to refresh the list first

This commit is contained in:
Derrick Hammer 2022-08-14 06:19:13 -04:00
parent b70c77eeda
commit 564306bed2
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { addHandler, handleMessage , log} from "libkmodule";
import { addHandler, handleMessage, log } from "libkmodule";
import type { ActiveQuery } from "libkmodule";
import PQueue from "p-queue";
import { ipfsPath, ipnsPath } from "is-ipfs";
@ -137,6 +137,9 @@ async function fetchFromRelays(
stream = undefined
) {
let error = new Error("NOT_FOUND");
if (0 == activeRelays.length) {
await refreshGatewayList();
}
for (const relay of activeRelays) {
let resp;
try {
@ -216,7 +219,7 @@ async function rpcCall(
stream(response?.data.data);
if (response?.data.done) {
socket.end();
resolve(true);
resolve(true);
}
}
});
@ -229,7 +232,7 @@ async function rpcCall(
force: true,
})
);
/* timer = setTimeout(() => {
/* timer = setTimeout(() => {
socket.end();
reject("timeout");
}, 10 * 1000) as NodeJS.Timeout;*/