How does IPFS (Interplanetary file storage) work?

Tola Ore-Aruwaji
4 min readSep 10, 2021
Photo by Omar Flores on Unsplash

The internet is such an important tool in our everyday life; we use it to communicate with friends, to consume media, to learn and handle our finances. The web as we know it has a problem, also the information on it is centralized, and all stored on big server farms that are controlled by a single company. The centralization brings a problem with it, like censorship because these contents are hosted on few servers, so it’s easy for the government to block access to them.

Centralizing servers allows companies to have complete control over how fast they can deliver many contents.

IPFS (InterPlanetary File System)

IPFS wants to make the web completely distributed by running it on top of a P2P network that works similarly to how BitTorrent works.

Let’s say you want to download a photo from the internet. When you do that, you tell the computer exactly where to find the photo. Here, the location of the photo is the IP address or the domain name. This is called “location-based addressing”. You tell the computer where to get the information but if that location isn't accessible, the server is down and you won't get the photo.

However, there is a high chance that someone else has downloaded that picture before and still has a copy of it, and yet your computer won't be able to grab a copy from that person.

To fix this, IPFS moves from “location-based” addressing to “content-based” addressing. Instead of saying /where/ to find a resource, you just say /what/ it is you want.

So how does this work?

Every file has a unique hash, which can be compared to a fingerprint. When you want to download a certain file you just ask the network: “who has the file with this hash? ” and someone on the IPFS network will provide it to you.

you might ask how do I know that the person hasn't tempered with the file?
Well, because you used a hash to request the file, you can verify what you have received. You request the file with a certain hash, so when you receive the file you check if the hatch matches with what you have received. (Security built-in!)

You can use hashes to address content by using deduplication. When multiple people publish the same file on IPFS, it will only be created once.

How does IPFS store files and make them accessible?

Files are stored inside IPFS objects and these objects can store up to 256kb worth of data. They can also contain links to other IPFS objects. A simple “Hello World” text file, which is very small, can be stored in a single IPFS object.

But what about files that are larger than 256kb? like an image or video, for instance? These files are split up into multiple IPFS objects that are all 256kb in size and afterward the system will create an empty IPFS object that links to all the other pieces of the file.

The data architecture of IPFS is very simple, and yet it can be very powerful. This architecture allows us to really use it as a file system. IPFS uses content-based addressing once something is added, it cannot be changed anymore. It’s an immutable data store, much like a blockchain.

How can you change stuff on it?

IPFS supports versioning of your files. Let’s say you are working on an important document that you want to share with everyone over IPFS, when you do that IPFS will create a new “commit object” for you. This object is really basic: it just tells IPFS which commit went before it and it links to the IPFS object of your file.

Now let's imagine that after a while you want to update this file what you have to do is add your updated file to the IPFS network and the software will create a new commit object for your file. This commit object now links to the previous commit. This process can be repeated endlessly. IPFS will make sure that your file, plus its entire history is accessible to the other nodes on the network.

The biggest problem IPFS faces is keeping files available.

Every node on the network keeps a cache of the files that it has downloaded and helps to share them if other people need them. But if a specific file is hosted by — let's say four nodes — and those nodes go offline, then that file becomes unavailable and no one can grab a copy of it.

The solutions are:

  • Either we incentivize people to store files and make them available or we can proactively distribute files and make sure that there is always a certain number of copies available on the network, and that is what exactly Filecoin intends to do.

Filecoin is created by the same group of people that have created IPFS. It’s basically a blockchain that is built on top of IPFS that wants to create a decentralized market for storage. If you have some free space, you can rent it out to others and make money from it in the process.

Filecoin creates a strong incentive for nodes to keep the files online for as long as possible because otherwise they won’t be rewarded. The system also makes sure that files are replicated on many nodes so they cannot become unavailable. This is a quick summary of Filecoin and how it intends to build on top IPFS to solve some of its issues.

I find IPFS a super interesting topic, and I really do believe that it is the future for storing your files and websites on the decentralized network.

Gracias

Enjoyed the read? Leave some ‘claps’ below so others can find this post. 🙂

Check out my other posts :)

https://thecraftman.medium.com/

--

--