What is Peer-to-Peer (P2P)?

In computer science, a peer-to-peer network consists of a group of devices that can store and share files. Each participant (node) is equivalent to a peer individual. That is, all nodes have the same rights and perform the same tasks.

In the field of financial technology, P2P usually refers to the transaction of digital currency or digital assets through a distributed network. A P2P platform allows buyers and sellers to trade directly without a middleman. Some websites can also provide a P2P trading environment for borrowers and lenders.

The P2P architecture is applicable to a variety of scenarios, but it really became popular in the 1990s when the first file sharing program was born. Today, peer-to-peer networks have become the core of most digital currencies and account for a large part of the blockchain industry. However, it is also used in various other distributed computer programs, including: web search engines, streaming platforms, online markets, and the InterPlanetary File System (IPFS) network protocol.


How P2P works

Essentially, a P2P system is maintained by users in a distributed network. Generally speaking, they do not have a central system administrator or server, because each node has a copy of the file -- it is equivalent to a user and a server for other nodes. Therefore, each node can download files from other nodes or upload files to them. The client devices of the traditional server system need to download files from the central server, which is the difference between P2P networks and other traditional service systems.

In a P2P network, files shared by connected devices are stored on their hard drives. Software applications are used to transfer shared data, and users can also find and download files from other devices. If a user downloads a specified file, he can act as the source of the file.

In other words, when a node acts as a user, it has to download files from other nodes. But if it works as a server, other nodes can download files from it. In fact, these two functions can be performed at the same time (for example, downloading file A and uploading file B).

Since each node can store, transmit and receive files, and as the user base of the P2P network grows, it becomes faster and more efficient. The distributed structure also makes the P2P system more resistant to network attacks. Unlike the traditional model, the P2P network has no single point of failure.

Based on their structure, we can classify P2P systems into three main types: unstructured peer-to-peer networks, structured peer-to-peer networks, and hybrid peer-to-peer networks.


Unstructured P2P Network

Unstructured peer-to-peer networks do not display a specific architecture of nodes. Participants can communicate freely with each other. These systems are resistant to high-frequency activity, which means that several nodes frequently enter and exit the network without any impact on the system.

Although unstructured peer-to-peer networks are easier to set up, they require more powerful CPUs and memory because search queries are sent to the largest number of peers. Especially if a small number of nodes can provide the required content, a large number of searches will flood the network.


Structured peer-to-peer network

Unlike unstructured peer-to-peer networks, structured peer-to-peer networks exhibit an organizational structure that allows nodes to efficiently search for files even if the content of the file is not widely used. In most cases, searches are performed by using hash functions to facilitate database lookups.

Relatively speaking, structured peer-to-peer networks are more efficient because they exhibit a higher level of centralization and require more startup capital and maintenance costs. In addition, structured peer-to-peer networks are less tolerant of high-frequency activities.


Hybrid peer-to-peer network

Hybrid peer-to-peer networks combine some features of the traditional client-slave architecture with the peer-to-peer architecture. For example, it may establish a central server to accelerate the connection between peers.

Unlike the other two models, the hybrid peer-to-peer network tends to present improved overall performance. It combines the advantages of each method and achieves efficiency and decentralization at the same time.


Distributed vs. Decentralized

Although peer-to-peer structures are distributed, their degree of decentralization varies. Therefore, not all peer-to-peer networks are decentralized.

In fact, many systems require a central authority to direct network activity, making them more or less centralized. For example, some peer-to-peer file sharing systems allow users to search and download files from other users, but they cannot participate in processes such as managing search queries.

Additionally, certain small networks controlled by a small number of users can also be said to be highly centralized, even though they may not have a neutral infrastructure.


The role of peer-to-peer in blockchain

In the early days of Bitcoin, Satoshi Nakamoto defined it as a "peer-to-peer electronic cash system." Bitcoin appeared in the public eye as a form of electronic cash. Through a peer-to-peer network, it can be transferred between two users, which requires the use of a distributed ledger, namely: blockchain.

In the blockchain, the peer-to-peer architecture allows Bitcoin and other digital currencies to be transferred around the world without the need for middlemen and any central server. If any user wants to participate in the process of verifying blocks, they can set up a Bitcoin node.

Therefore, there are no bank steps or transaction records in the Bitcoin network. Instead, the blockchain serves as an electronic ledger that publicly records all transaction activities. Basically, each node has a copy of the blockchain and compares it with other nodes to ensure the correctness of the data. The Bitcoin network can quickly eliminate various errors and malicious activities.

Nodes can play a variety of different roles in the blockchain. For example, full nodes verify transactions through consensus rules, thereby ensuring the security of the network.

Each full node maintains a complete, updated copy of the blockchain — allowing these copies of the blockchain to work together to verify the true state of the distributed ledger. It is important to note that not all validating nodes are miners.


Advantage

The peer-to-peer architecture of blockchain has many advantages. More importantly, compared with the traditional master-slave architecture, the peer-to-peer network has higher confidentiality. Most nodes are almost resistant to the "Denial of Service (DoS)" attacks that have damaged many systems.

Likewise, since data is added to the blockchain with the unanimous consent of a majority of nodes, it is nearly impossible for an attacker to change the data. This is especially true in large networks like Bitcoin. However, relatively small blockchains are vulnerable to attacks because one individual or organization often controls a large number of nodes (this is known as a 51% attack).

Therefore, under the premise of unanimous agreement of the majority of nodes, the distributed peer-to-peer network makes the blockchain more resistant to malicious network attacks. The peer-to-peer model is the main reason why the Bitcoin network can achieve Byzantine fault tolerance.

In addition to security, the peer-to-peer architecture allows the digital currency blockchain to avoid central agency censorship. Unlike ordinary bank accounts, digital currency wallets cannot be frozen or consumed by the government. Personal payment processing and content platforms can also avoid corresponding censorship. Some online merchants have adopted digital currency payment methods to avoid their payments being interfered with by third parties.


limitation

Despite all these advantages, the use of P2P networks in blockchain also has certain limitations.

Since the distributed ledger must be upgraded on every node, adding transactions to the blockchain requires huge computer power. While this improves security, it also greatly reduces efficiency and has become one of the main obstacles to the expansion and promotion of blockchain networks. However, cryptographers and blockchain developers are working on alternatives to solve scalability issues. Several obvious examples include the "Lightning Network", "Ethereum Plasma" and the "Mimblewimble Protocol".

Another potential limitation concerns possible attacks during a hard fork. Since most blockchains are decentralized and open source, nodes are free to copy and modify the code and fork from the main chain, forming new parallel networks in this way. Hard forks are completely normal and not a threat. However, if certain security measures are not properly implemented, both chains could be affected by replay attacks.

In addition, the distributed nature of P2P networks makes them relatively difficult to control and regulate. This problem is not limited to blockchains, as some P2P applications and companies are also involved in illegal activities such as copyright infringement.


Summarize

The peer-to-peer architecture can be developed and applied in many different aspects. Its core position in the blockchain has also contributed to the birth of digital currency. By distributing transaction ledgers in a large network of nodes, the peer-to-peer architecture provides advantages such as security, decentralization, and prevention of regulation.

In addition to its advantages in blockchain technology, P2P systems can also be applied to other distributed computing applications, ranging from file sharing networks to energy trading platforms.