Compare commits

..

No commits in common. "3955ff2c292379ba473ed341a8d00a51fb54d839" and "fd2d66d2c4713d266b4b906e9b560310d0e9a3a1" have entirely different histories.

1 changed files with 14 additions and 33 deletions

View File

@ -238,10 +238,7 @@ async function handleStat(aq: ActiveQuery) {
aq.respond(
JSON.parse(
JSON.stringify(
await fs.stat(
getCID(aq.callerInput.cid),
aq.callerInput.options ?? {}
)
await fs.stat(aq.callerInput.cid, aq.callerInput.options ?? {})
)
)
);
@ -263,10 +260,7 @@ async function handleLs(aq: ActiveQuery) {
aborted = true;
});
const iterable = fs.ls(
getCID(aq.callerInput.cid),
aq.callerInput.options ?? {}
);
const iterable = fs.ls(aq.callerInput.cid, aq.callerInput.options ?? {});
for await (const item of iterable) {
if (aborted) {
@ -292,10 +286,7 @@ async function handleCat(aq: ActiveQuery) {
aborted = true;
});
const iterable = fs.cat(
getCID(aq.callerInput.cid),
aq.callerInput.options ?? {}
);
const iterable = fs.cat(aq.callerInput.cid, aq.callerInput.options ?? {});
for await (const chunk of iterable) {
if (aborted) {
@ -313,24 +304,25 @@ async function handleIpnsResolve(aq: ActiveQuery) {
await activePeersDefer.promise;
if (PeerManager.instance.ipfs.libp2p.getPeers().length === 0) {
activePeersDefer = defer();
}
await activePeersDefer.promise;
if (!aq.callerInput || !("cid" in aq.callerInput)) {
aq.reject("cid required");
return;
}
const prefix = substr(aq.callerInput.cid, 0, 1);
if (!(prefix in basesByPrefix)) {
aq.reject("invalid multibase found in CID");
return;
}
const base = basesByPrefix[prefix];
const cid = CID.parse(aq.callerInput.cid, base);
try {
return aq.respond(
(
await IPNS.resolve(
peerIdFromCID(getCID(aq.callerInput.cid)),
aq.callerInput?.options
)
await IPNS.resolve(peerIdFromCID(cid), aq.callerInput?.options)
).asCID.toString()
);
} catch (e: any) {
@ -338,17 +330,6 @@ async function handleIpnsResolve(aq: ActiveQuery) {
}
}
function getCID(cid: string): CID {
const prefix = substr(cid, 0, 1);
if (!(prefix in basesByPrefix)) {
throw new Error("invalid multibase found in CID");
}
const base = basesByPrefix[prefix];
return CID.parse(cid, base);
}
async function handleGetActivePeers(aq: ActiveQuery) {
await ready();