*switch to ipfs http client. ipfs-core used by mistake
This commit is contained in:
parent
9d2979067a
commit
6437e93fc4
|
@ -9,7 +9,7 @@ import { CID } from "multiformats/cid";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import toStream from "it-to-stream";
|
import toStream from "it-to-stream";
|
||||||
import type { StatResult } from "ipfs-core/dist/src/components/files/stat";
|
import type { StatResult } from "ipfs-core/dist/src/components/files/stat";
|
||||||
import * as IPFS from "ipfs-core";
|
import * as IPFS from "ipfs-http-client";
|
||||||
|
|
||||||
interface StatFileResponse {
|
interface StatFileResponse {
|
||||||
exists: boolean;
|
exists: boolean;
|
||||||
|
@ -26,7 +26,7 @@ interface StatFileSubfile {
|
||||||
size: number;
|
size: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
let client: IPFS.IPFS;
|
let client: IPFS.IPFSHTTPClient;
|
||||||
|
|
||||||
import { utils } from "ipfs-http-response";
|
import { utils } from "ipfs-http-response";
|
||||||
|
|
||||||
|
@ -138,7 +138,6 @@ async function fileExists(
|
||||||
path?: string,
|
path?: string,
|
||||||
fullPath?: string
|
fullPath?: string
|
||||||
): Promise<Error | StatResult> {
|
): Promise<Error | StatResult> {
|
||||||
client = client as IPFS.IPFS;
|
|
||||||
let ipfsPath = normalizePath(hash, path, fullPath);
|
let ipfsPath = normalizePath(hash, path, fullPath);
|
||||||
try {
|
try {
|
||||||
const ret = await client.files.stat(`/ipfs/${ipfsPath}`);
|
const ret = await client.files.stat(`/ipfs/${ipfsPath}`);
|
||||||
|
@ -162,7 +161,7 @@ async function resolveIpns(
|
||||||
const plugin: Plugin = {
|
const plugin: Plugin = {
|
||||||
name: "ipfs",
|
name: "ipfs",
|
||||||
async plugin(api: PluginAPI): Promise<void> {
|
async plugin(api: PluginAPI): Promise<void> {
|
||||||
client = await IPFS.create();
|
client = await IPFS.create({ host: "127.0.0.1" });
|
||||||
api.registerMethod("stat_ipfs", {
|
api.registerMethod("stat_ipfs", {
|
||||||
cacheable: false,
|
cacheable: false,
|
||||||
async handler(request: RPCRequest): Promise<RPCResponse | null> {
|
async handler(request: RPCRequest): Promise<RPCResponse | null> {
|
||||||
|
|
Loading…
Reference in New Issue