Skip to content

Commit

Permalink
paused due to: ipfs/helia#182
Browse files Browse the repository at this point in the history
  • Loading branch information
keiner5212 committed Jun 28, 2024
1 parent 6172fa9 commit d8ae5fa
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 49 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"@helia/unixfs": "^3.0.0",
"@libp2p/autonat": "^1.0.22",
"@libp2p/bootstrap": "^10.0.25",
"@libp2p/circuit-relay-v2": "^1.1.0",
"@libp2p/dcutr": "^1.0.22",
"@libp2p/identify": "^2.0.3",
"@libp2p/kad-dht": "^12.0.18",
"@libp2p/upnp-nat": "^1.1.0",
"@libp2p/webrtc": "^4.1.0",
"@libp2p/websockets": "^8.0.25",
"blockstore-idb": "^1.1.8",
"datastore-idb": "^2.1.9",
Expand Down
161 changes: 142 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/hooks/useCommitFile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useCallback } from "react";
import { useHelia } from "@/hooks/useHelia";
import { CID } from "multiformats/cid";
import { provideCid } from "./useHelia";

function getUint8ArrayFromFile(file) {
return new Promise((resolve, reject) => {
Expand All @@ -27,8 +28,9 @@ export const useCommitFile = (setCidString, setCommittedFile) => {
setCommittedFile(null);
try {
const buffer = await getUint8ArrayFromFile(file);
const cid = await fs.addBytes(buffer, helia.blockstore);
const cid = await fs.addBytes(buffer);
setCidString(cid.toString());
await provideCid(cid, helia);
} catch (e) {
console.error(e);
}
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useHelia.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export const useHelia = () => {
const { helia, fs, error, starting, peers } = useContext(HeliaContext);
return { helia, fs, error, starting, peers };
};

export async function provideCid(cid, helia) {
for await (const event of helia.libp2p.services.dht.provide(cid)) {
console.log(event)
}
}
Loading

0 comments on commit d8ae5fa

Please sign in to comment.