In August of 2015 I travelled across parts of Europe to BattleMesh v8, and I was lucky enough to be able to travel with some of the developers behind IPFS. It's now February, and though I've been meaning to write about it for a while, and I'm only just getting around to it now. Life has been hectic, but I figure I'll start with a simple article and I can write more later.
What is IPFS?
The InterPlanetary File System...
IPFS is a distributed, content-addressable datastore. It's pretty complicated to try to explain it that way, but reasonably simple to explain how to use it, so that's what I'll do.
Suppose you have a picture you want to share:
You can do so from the command line:
# download the file wget transitiontech.ca/assets/goat.jpg # add it to ipfs ipfs add goat.jpg
IPFS should print a line that looks like this:
added QmevJcqiuxiVyjemunyeN6P9wSTXgHgjMFXMvoQywX9iqY goat.jpg
That long string of nonsense is a cryptographic hash of the file. If you run the same command a second time, you should get the same output. This is important, because it shows that any file is identifiable by its hash. You can change the name of the file, but it's the contents that matter.
Now that the file is in the IPFS datastore, you can ask for a copy using that hash:
ipfs get QmevJcqiuxiVyjemunyeN6P9wSTXgHgjMFXMvoQywX9iqY
Once again, ipfs gives you a little information about the file you retrieved:
Saving file(s) to QmevJcqiuxiVyjemunyeN6P9wSTXgHgjMFXMvoQywX9iqY 477.50 KB 0
You can try opening up the file that was saved, and you should see that it's the same file you added to IPFS.
This is the content-addressable aspect of IFPS. You don't ask for files by their location, you ask for them by their unique identifier.
Why is this interesting?
I've demonstrated that IPFS can work on a single computer, but in fact, it works the same way across very large networks. If a friend of yours is running IPFS, they can ask for the identifier of a file you added to your datastore, and the IPFS network will find it on your hard drive and deliver it to them. They don't have to specify where it is, just what it is, and it ends up on their hard drive just the same as how you retrieved it.
When you ask for a file, IPFS tries to find the nearest copy of it. As such, when your friend's friend tries to retrieve the same file, they won't retreive it from you, they will retrieve it from your friend (assuming they are closer). This means that even though you may have been the first person to host a file, as more and more people become interested in that file the amount of requests to retrieve it from your datastore will not increase significantly. The burden of sharing files is distributed across the swarm of peers who are interested in sharing it.
There are other systems which work similarly, like torrent files, however, IPFS does not require any tracker to tell peers how to find each other. Nodes in the network all share the work of locating files without the need for any hierarchy.
IPFS is still under active development, and new features are being added all the time. The reference implementation is being written in Go. You can build it yourself, or download pre-built binaries. When I first installed it I used their npm installer, and that has worked well for me so far.
There are many more commands for ipfs besides
get, and more commands are being added all the time.
I expect that I'll write more on the topic, but if you're really interested I recommend joining their IRC channel: #ipfs on Freenode