This is my solution of Blockchain implementation for the fulfillment of Assignment-1 of the course Introduction to Blockchain (Instructor : Dr. Debashis Das; Run : Fall 2022).
For adding Miner(s), follow these steps :
- Copy and paste any of the Miners' folder and edit the
Miner_x.py
file in the appropriate places. Replacex
with suitable number. - Remove all Users and Transactions from
users.json
andtransactions.json
files respectively. Keep theall_users.json
andblockchain.json
unchanged. - Make necessary changes in Miner's number in
verify_chain_thread.py
file.
For leader selection, a separate leader_selection_thread.py
has been written. Run this program in a separate Terminal/CMD and leave it running infinitely. The main functionalities of this code are -
- Initialize Leader Miner
- Collect all unrecorded transactions in the whole network
- Mine block by following all protocols (e.g. proper PoW, timestamp etc.)
- Get the block verified from other Miners
- If the acceptance is more than 75%, add the block in the blockchain
This is a Menu Driven code from the perspective of an End User. The user has to register using a unique username and use that to perform various operations (mainly, transactions with other users in the network) through this.
- Open one terminal/CMD for each of the Miners and start executing
verify_chain_thread.py
. This will keep on verifying the existing blockchain for malicious/altered blocks at a certain interval. - Open one terminal/CMD and start executing
leader_selection_thread.py
. This will keep on assigning Mining workload on each of the miners in a sequential manner. - Open a Terminal/CMD and start executing
UserOperations.py
. From here, you can register yourself as a user. Add multiple users in the network and perform some transactions. You can see the changes to be reflected on the corresponding files inside Miners' folders.
This is a continuation of Assignment-1. Here, one needs to find certain values from the blockchain network created in Assignment-1.
- Open one terminal/CMD and run
A2.py
. - For Q3, you need to enter a valid hash of a block.
- Executing the script will produce necessary outputs.