https://github.com/pratik-codes/go-blockchain
A light weight blockchain (inspired by bitcoin architecture) written in Golang for devs with interest in blockchain architecture.
https://github.com/pratik-codes/go-blockchain
blockchain go grpc web3 websock
Last synced: 3 months ago
JSON representation
A light weight blockchain (inspired by bitcoin architecture) written in Golang for devs with interest in blockchain architecture.
- Host: GitHub
- URL: https://github.com/pratik-codes/go-blockchain
- Owner: pratik-codes
- Created: 2024-08-18T22:03:33.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-11-03T17:22:44.000Z (8 months ago)
- Last Synced: 2025-03-24T16:35:11.414Z (4 months ago)
- Topics: blockchain, go, grpc, web3, websock
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blockchain Interaction: Central Server & Miner Nodes
## **Step-by-Step Interaction When a User Adds a Transaction Request:**
```text
User Central Server Miners (M1, M2, ...)
| | |
|------ Add Transaction -------------| |
| | |
| | |
| 1. Broadcast Transaction -------------------|
| |--------- Receive Transaction --------|
| | |
| | |
| 2. Add transaction to txn pool |
| | |
| |--------- Broadcast new txns -------->|
| | |
| 3. Wait for block mining 3. Start mining
| | |---|
| | | |--> Do proof of work
| | |---|
| | |
| | |---|
| | | |--> Successfully mine a block
| | |---|
| | |
| | <----- Broadcast new block --------- |
| 4. Verify Block 4. Verify Block
| 5. Add Block to chain 5. Add Block to chain
| 6. Adjust difficulty 6. Adjust difficulty
| | |
| | |
| | ----- Broadcast new block ---------> |
| | to |
| | other miners |
| | |
| | |
|------- Notify users of success ----| |
```## Central Server Responsibilities:
1. Broadcast Transaction:
When a user adds a new transaction, the central server broadcasts it to all connected miners.2. Manage Transaction Pool:
The server adds the transaction to its own transaction pool and removes transactions that are already included in a mined block.3. Broadcast New Transactions:
The server keeps miners updated by broadcasting new transactions regularly.4. Verify and Add Block:
Once a block is mined by any miner, the central server verifies it and broadcasts the new block to the rest of the miners.5. Adjust Difficulty:
After receiving each new block, the server adjusts the difficulty level to maintain a steady block time.## Miner Server Responsibilities:
1. Receive Transactions:
Each miner receives new transactions from the central server and maintains its own transaction pool.2. Mine Blocks:
Miners mine blocks at a fixed interval by performing Proof of Work (PoW). This involves finding a valid hash based on the difficulty level.3. Broadcast Mined Block:
After successfully mining a block, the miner broadcasts it to the central server, which further distributes it to all other miners.4. Verify Block:
Each miner verifies the received block and checks if the chain is valid. Smaller or erroneous chains are rejected.5. Update Blockchain:
The miner updates its local copy of the blockchain and adjusts the mining difficulty based on the central server’s broadcast.