Blockchain - a distributed P2P network
Tags: blockchain, developer, networks, webdev
Published: 2022-01-23 14:26:23

##Network Types

<u>**Centralized network**
</u>
- Built around a single server and use client-server architecture. 
- Advantages: Efficiency, consistency and affordability. 
- Disadvantages: single point of failure can be risk for organizations, limited scalability, lack of bandwidth

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pju715bron466kzgzujc.png)
 

<u>**Decentralized network** 
</u>
- Distributes the workload among different machines. 
- Benefits: reliability, scalability and privacy.There is no single point of failure. Information passes through a number of different points. 
- Disadvantages: requires more machines.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tqc2c39bg2umw6weos8.png)
 

<u>**Distributed Network**</u> spread over different networks. Part of distributed computing architecture. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwh3szwjb4093nqcmllw.png)
 

<u>**P2P network** 
</u>
- Consists of a group of devices that collectively store and share files. 
- Each participant (peer) has equal power and each node holds a copy of the file and each node can download nodes from other nodes. 
- In a P2P network there is no central governing authority. 
- All nodes are equal to each other. Anyone connected to this network can share and download any file shared by other users in the network
- A P2P network refers to the exchange of digital assets or cryptocurrencies via a distributed network and there is no need for intermediaries. P2P networks are at the center of most cryptocurrencies and other stributed computed applications such as Netflix, Amazon, Google.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqg5km4xesn4rlcs4i4m.png)
 

## P2P networks categorized into 3 main types :

- <u>**Unstructured**</u>, no specific organization of nodes. Participants communicate randomly with one another. They are robust and require higher memory
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8awmypcuh3zivzwdjci.png)
 
- <u>**Structured**</u> allows nodes to search for files even if the content is not available. They are more efficient but require higher maintenance and setup costs but also they are less robust.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n5tl3savpg5jwxdjq0ku.png)
 
- <u>**Hybrid**</u> Combines the conventional client server model with some facets of the peer-to-peer architecture and improve overall performance

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xorsx8sxfptmteuy17nr.png)
 

##Server based vs P2P network


<u> Server based network
</u>
- Network security and storage are controlled and managed by one or more servers
- More complex and costly to manage and set up compared to a P2P network
- Are good for businesses that are having more than 10 computers

<u> P2P network
</u>
- Consists of devices that are collectively store and share files.
- There is no central regulatory authority
- Anyone can share and download any file which is shared by other peers in the network


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xrfel53mld80vivjlkm.png)
 

## P2P network & Blockchain

- In 2008, Satoshi Nakamoto defined Bitcoin as a Peer-to-peer Electronic Cash System
- P2P allows Bitcoin and other cryptocurrencies to be transferred worldwide, without the need for any central server.
- Anyone can set up a Bitcoin node if they want to participate in the process of validating and verifying blocks
- Blockchain acts as a digital ledger that publicly records all the activity. If any malicious activity is found the network quickly rejects it
- Nodes provide security to the network by verifying transactions against the system’s consensus rules
- The P2P architecture of blockchains provides benefits of greater security than traditional client-server based networks as distribution of large numbers of nodes creates an immune system to Denial-of-Service attack.
- Changing data is almost impossible in a distributed P2P network especially when we talk about big networks such as Bitcoin
- Unlike standard bank accounts, cryptocurrency can’t be drained or frozen by governments.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mxu1vhbawcimgaevzk28.png)