What is the use of Swarm for Ethereum developers?


If you’re interested in swarm and want to know what it can do for Ethereum developers, you’re in the right place.

Blockchain is currently the No.1 technology in LinkedIn, so you must learn more about Ethereum and master cryptocurrency comprehensively.

Now let’s talk about: what is swarm and why is it useful for Ethereum developers? This article will introduce how Ethereum’s infrastructure and storage work, as well as a key aspect of back-end development: how data storage works.

Ethereum is a decentralized network, which means that the file storage of Ethereum protocol also follows this principle.

Swarm 101

Swarm is one of my favorite Ethereum projects. In my opinion, swarm is the core part of the whole decentralized ecosystem. According to Ethernet, swarm is an uncensored, unauthorized, decentralized storage and communications infrastructure layer.

What is the use of Swarm for Ethereum developers?

The main purpose of swarm is to become the decentralized storage of DAPP code, user data, blockchain data and state data. Swarm provides various basic services for Web 3.0, including node to node messaging, media streaming, decentralized database services and scalable state channel infrastructure for decentralized service economy.

Record keeping of swarm

Before deeply studying the technical structure of swarm, we must first understand how swarm records, stores and maintains data, and how the retriever can access data at any time.

The principle is to store documents in random nodes. Nodes only keep the tags of root hash and subsequence directory hashes. Then, rendering the document is very simple. In essence, the requester just extracts page. HTML from the list entry.

Cloud mining machine to dig fil, you only need a mobile phone to participate, coffee aacd314 to learn more

How does swarm render requests?

Swarm’s underlying infrastructure provides these services. Swarm works well because each service can contribute resources to each other. These contributions are accurately calculated on a point-to-point basis. Nodes exchange resources for resources, and provide monetary compensation to nodes with less consumption.

Swarm uses existing smart contract platforms such as Ethereum to implement its incentive mechanism, which will be explained in detail below. But first let’s look at swarm’s data structure. Swarm decentralized storage system consists of three parts

Chunks: This is a limited size (up to 4K) data block, which is the basic unit of storage and retrieval in swarm. Links to the address.

Reference: unique identifier of the file, allowing the client to retrieve and access the content.

Manifest: describes the data structure of a file collection. Specify the path and the corresponding content hash to allow URL based content retrieval.

The figure above shows how swarm presents a request. Essentially, chunk represents hash information such as “page. HTML” or “page. CSS”. Each chunk contains a reference in the manifest that tells the requester how to retrieve and present information.

Next, let’s look at the architecture of swarm and how different nodes write and upload data to the network.

Swarm stack: Upload

Initially, distributed pre image archiving (DPA) splits each blob into many chunks. DPA randomly selects which blocks to store. After that, these nodes store blocks locally. These data blocks are marked and placed in containers of random nodes. After receiving the data, the node will communicate with other nodes in the same network or address space.

Swarm upload process

How does swarm store each piece of data?

The node automatically synchronizes the data according to the time stamp of each block. As a result, there will be no data loss or blob corruption. Finally, each bin (0, 1,…, 31) shows how nodes in the same address space store related blocks.

Due to node storage, synchronization and information sharing, any given node can send the whole data segment back to the retriever.

It must be said that the requester can retrieve a piece of data at any time (asynchronous model).

What is the use of Swarm for Ethereum developers?

Swarm storage layer

Overview of swarm storage layer

The actual storage layer of swarm consists of two main components: localstore and netstore. The memory cache (memstore) and persistent disk storage (dbstore) write localstore. Netstore extends localstore to swarm distributed storage and implements DPA.
What is the use of Swarm for Ethereum developers?
The file store is the local interface for storing and retrieving files. When a file is handed over to the file store, the file store partitions the document into a Merkle hash tree and returns its root key to the caller. This root key can then be used to retrieve documents.

Finally, the filestore uses swarm hash and netstore to retrieve the root block of the document for the user.

Overview of swarm

From the end user’s point of view, swarm does not affect navigation or behavior. But on the back end, the peer-to-peer storage network hosts content, not a single server. Due to the built-in incentive system, this peer-to-peer network is self-sustaining. Only through the use of public blockchains that allow transaction resources to pay, can incentives be possible.

Swarm also deeply integrates Ethereum’s devp2p multi protocol network layer. Devpp is a group of network protocols, which essentially constitute the Ethereum peer-to-peer network.

In addition, swarm is linked to the Ethereum blockchain for domain name resolution (ENS), service payment and content availability insurance.

Swarm vs IPFS vs Filecoin

Finally, highlight the key differences between swarm and other distributed file stores, such as IPFs and filecoin.

IPFs, or interstellar file system, is a point-to-point hypermedia protocol, which aims to make the network faster, more secure and more open. Filecoin is a decentralized file storage system, which uses token to motivate node operators.

In order to better understand the difference between swarm and the two, we make a few simple comparisons

The core storage component of swarm is immutable content addressing, rather than general distributed hash table, namely DHT (DHT is used in IPFs).

Swarm, filecoin and IPFs are different in network communication layer and peer-to-peer management protocol.

Swarm is deeply integrated with Ethereum blockchain, and the incentive system benefits from smart contract and semi stable peer pool. Filecoin uses proof of retrievability as part of mining. IPFs has no built-in incentive mechanism. Learn more about aacd314