Where the files are stored

I’ve read that IPFS uses the DHT Kademlia and so when I add a file on the network it is stored on the peer which has the IDPeer closest to the file’s hash but I didn’t understand where the file is effectively stored. Can someone help me?

Thank you

The DHT is used to keep track of the peerIDs that store the IPFS data. The nodes that store the IPFS data will will be the nodes that have pinned the content.

Ok but then what is the difference between dht provide and add?

“where the file is effectively stored” is initially only on your node. Unless someone else knows of it, it will only be on your node. If you tell someone or they learn of the CID of your file, then they can request it from the network (only you initially). If they then pin it to their node, it will remain there. If they don’t pin it, in time it will be discarded (garbage collection).

1 Like

Sorry to disappoint you, but:

The DTH stores the information where to find the content, but not the content itself.

If you don’t share the CID of your file - and noone else has the same file and shares the CID, it will remain just on your node.

If you want someone else to receive the file, you have to share the CID of it.

If you want to share more than one file with someone, you can place more files in one folder, and share the folder’s CID.

Note that, while you can edit a folder in any way, the CID of it will change (since the content has changed), and you have to share the new CID with someone who should receive the newly edited version.

Best regards

Ruben

provide = DHT has some particular content and so therefore can ‘provide’ it to network, add = content add to DHT

Yes but then what does it mean that the DHT stores the contents on the peer closest to the file hash? If it tracks the peers that have the file - or those who pinned it - then I can’t understand when Kademlia comes into play.

Hi

IPFS is peer to peer & runs on a distributed ledger. The files are stored locally on users’ personal computers. You access the files for the server that’s closest to your location.

This is not accurate. There is no distributed legdger involved in IPFS.

This is also not accurate. Files are downloaded from the servers that have them, regardless of location. Those servers are found using the DHT.

2 Likes

The idea of a DHT is, that you generate a hash of a file and search on the network for a peer with a similar hash. Then you send the information that you can ‘provide’ this hash on the peer you identified before.

If someone is searching for the file he has to have the hash, the peer in the network which is close to the hash can now answer with the information that you can provide the file.

Then the person who is searching for the file, connects to you, to receive the file.

Basicaly, when you ask for the file Qm12345, first you ask for the guys responsible for knowing who has it (the book-keepers for this file are the ones with a peer ID close to the content, such as Qm12344 and Qm12348).
These guys will answer with the peerID of the peers having the content. These “providers” can have any peedID, such as Qm93758, Qm22940 and Qm19656. These peers can be the original provider of the data, some peers that requested the data not long ago and still have it hot in their cache, or some peers that “pinned it” meaning requested it and willing to keep it available for a while.
Notice that the data is never sent from the original provider if no one request it, especially not the DHT. The only piece of data sent when adding a file to IPFS is “hey guys, I have this data and can sent it to you if you need it”. The DHT only stores the location/routing information, not the data. It’s a bit like DNS storing where to find website, not the website themselves. The only difference is that the list is split and that you ask Alice for what begins by A, Bob for what begins by B, etc.

NB: you actually query the DHT a second time to know how to contact the providers (a second mapping providers/addresses along with the above contentID/providers mapping)

2 Likes

We also split DNS: for .de is someone else asked than for .com. :kissing_smiling_eyes::notes:

Yeah, true. But you get the point anyway :wink:

1 Like

Oh thank you very much, it’s clear now. :blush: :blush:

1 Like

sounds like your looking for static. I ho
e you would right this measure

[/spoiler]

1 Like