refactor: our custom ipns cache should no longer be needed

This commit is contained in:
Derrick Hammer 2023-07-17 10:43:48 -04:00
parent 2e7fdef740
commit 93dc1e76de
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 1 additions and 9 deletions

View File

@ -17,10 +17,8 @@ import * as path from "path";
import { CID } from "multiformats/cid";
import { fileTypeFromBuffer } from "file-type";
import extToMimes from "../mimes.js";
import NodeCache from "node-cache";
export default class IpfsProvider extends BaseProvider {
private _ipnsCache = new NodeCache({ stdTTL: 60 * 60 * 24 });
private _client = createClient();
async shouldHandleRequest(
@ -76,13 +74,7 @@ export default class IpfsProvider extends BaseProvider {
try {
if (ipnsPath(cid)) {
const cidHash = cid.replace("/ipns/", "");
if (this._ipnsCache.has(cidHash)) {
cid = this._ipnsCache.get(cidHash);
} else {
cid = await this._client.ipns(cidHash);
this._ipnsCache.set(cidHash, cid);
}
cid = await this._client.ipns(cidHash);
cid = `/ipfs/${cid}`;
}