0

https://www.youtube.com/watch?v=PlvMGpQnqOM After watching the above tutorial on the IPFS protocol, I've learned that nodes use a distributed hash table(DHT) to query CID from other peers and fetch data. This leads to the logical conclusion that in order for me to let other peers download data from my node after adding it to IPFS using the IPFS.add() method, either the IPFS.add() method needs to include functionality for propagating my updated local DHT(new CID, peerID pair) to other connected peers or there has to be separate methods in the JS IPFS source code that allows me to propagate my local DHT to other peers. In essence, I want to know exactly how this works: "When you add a file to IPFS, you're putting it in your own node and making it accessible to peers on the network while your node is running"(https://proto.school/regular-files-api/03). Hence, I am religiously studying the JS IPFS source code(https://github.com/ipfs/js-ipfs) to find this functionality to no avail. Please help me find the methods within JS IPFS that allow other peers to recognize that I have a certain file that I've added to IPFS.

rasputin
  • 31
  • 5
  • 1
    maybe `ipfs.dht.provide()` passing it the added file's CID? https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/DHT.md#ipfsdhtprovidecid-options – GrafiCode Sep 11 '22 at 09:23
  • So am I correct in stating that even after I store a file to ipfs using the add method, other peers won't be able to fetch the file from me until I call ipfs.dht.provide() ? – rasputin Sep 11 '22 at 09:40
  • I don't really know, as far as I can see, the `add()` method only `Import a file or data into IPFS` so I think you still have to provide the cid https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md#ipfsadddata-options – GrafiCode Sep 11 '22 at 09:48
  • Hmm... I used two separate devices to test whether the add method alone allows peers to download files with CID and indeed it does work. This makes me even more frustrated since this means IPFS.add() somehow tells other peers that a certain node has a certain file - dht or whatnot - but for the love of god I can't find the exact methods that accomplishes this. – rasputin Sep 12 '22 at 09:36

0 Answers0