I have done some research on js ipfs to realize that, by default, my local ipfs node does not use DHT based queries to fetch files with CIDs nor propagate my local DHT to other connected peers once the local node downloads the file. Instead it makes use of preload nodes, which are essentially delegated routing nodes that receives my http request that contains the CID of the file I want, and queries DHT on my node's behalf. I fully understand on the surface level how delegated routing works, but I want to understand how delegated routing works under the hood. I specifically have a difficult time on what the source code of a delegated routing node should look like in order to receive http requests and return files after a DHT query, as there are no good tutorials on this so far. I am also confused on how exactly a delegated routing node makes the fetched files viewable through my local node's directory. While analyzing the js ipfs source code, I found out that the IPFS.cat() method eventually displays the contents of a file by using the fs module's readFile method on a local path. I don't know how this is possible, since there is nowhere in the actual http request method sent from the local node that saves the returned response in my local directory, let alone access the local directory through the os module. In summary, I want to understand how to set up a delegated routing node to do the following: 1) receive http requests and do DHT queries 2) return the result of the DHT query and also cache the result to the local directory of the IPFS node that had sent the http request. It would be great if there were some good tutorials on this, but resources like these - https://github.com/libp2p/js-libp2p/tree/master/examples/delegated-routing - only show how to connect to a delegated routing node. It doesn't really teach us how to set up a fully functioning delegated routing node.
Asked
Active
Viewed 120 times