Decentralized Storage Explained
Blockgeeks Blockgeeks
53.8K subscribers
23,736 views
0

 Published On Dec 20, 2017

Decentralized Storage Explained - https://blockgeeks.com/

In this lesson we’ll learn about decentralized storage and some services that are available today like IPFS and Swarm. You can think of decentralized storage as a peer-to-peer network where members pool together their disk space to create a shared global memory, kind of like Dropbox but decentralized.

Both IPFS and Swarm are similar in that they are opensource decentralized storage solutions, but they differ in implementation and approach. IPFS, which stands for interplanetary file system, is a protocol that was published by an organization called Protocol Labs. The first implementation of the IPFS protocol was written in the Go language and published in early 2015, and today there are several alpha release implementations available including in javascript.

Swarm is also a protocol, and is part of the Ethereum holy trinity that makes up the serverless world computer, which consists of Swarm, Ethereum and Whisper. These three infrastructure projects are part of a broader vision that provides a completely decentralized alternative to the currently centralized web. Ethereum would provide the computation power; Swarm would provide the storage layer; And Whisper would provide a messaging layer. Swarm and Whisper are not quite as far along in their roadmaps as Ethereum. But a proof-of-concept Swarm implementation written in the Go language is included as part of the geth client since version 1.5

You may have noticed I said that both projects are either in alpha or proof-of-concept stages, meaning theyre not quite yet ready for the production spotlight. But understanding the role of decentralized storage in the future web is important, so you should know how to make use of these tools. As these projects evolve and mature, they will become increasingly production ready.

Let’s start by looking at how to use Swarm. Since Swarm is already part of the Ethereum stack, a proof-of-concept Go language implementation exists as part of geth. So to activate swarm, we need to download and build geth and swarm from source. To do this, we need to have Git and Go installed in our environment. You can do this easily using the command brew install go git.

Then you need to make sure your Go environment is setup correctly. You can do this by creating a folder called go in your home folder, and then exporting an environment variable called $GOPATH which points to this folder.

We’ll then install from source by downloading the go-ethereum source code from their github

mkdir -p $GOPATH/src/github.com/ethereum
cd $GOPATH/src/github.com/ethereum
git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
git checkout master
go get github.com/ethereum/go-ethereum

And now we can compile geth and swarm from source:

go install -v ./cmd/geth
go install -v ./cmd/swarm

We’re now ready to run the swarm daemon by using the binary in our $GOPATH. You can add this bin folder to your PATH for convenience. If you run swarm version, we can see that we are on version 1.8.

To use Swarm, you need to have an Ethereum account. You can do this quickly using geth account new. After entering a password, this will print out the new account address that we will use to join the Swarm network. You can copy the public address to your clipboard.

To run Swarm we first need to make sure we have geth running. Then in a separate tab we run swarm and point it to our Ethereum account using the —bzzaccount option and pasting in our public address. It will prompt for your password to unlock the keyfile for Swarm, and then start up a local Swarm node on port 8500.

Now we can easily upload files using swarm command line tools by simply calling swarm up followed by the path of the file you want to upload. Swarm doesn’t support encryption yet, so make sure you dont upload any sensitive files. After uploading, you’ll get a unique hash printed out for this file that points to it on the Swarm network. Let’s upload our index.html from our previous blockchain explorer example.

To read more check out https://blockgeeks.com/

show more

Share/Embed