A blockchain simulator in Python and Flask.
Blockchain is a digital ledger that is distributed among the nodes of a peer-to-peer network. This solution to Byzantine Failures requires maintaining a global public append-only log. Each block in the blockchain contains a cryptographic hash of the previous block, a timestamp, and transaction data (generally represented as a Merkle tree, where data nodes are represented by leaves).
This project implemented my own version of blockchain. This goal required implementing a basic abstract representation of blockchain and basic algorithms and operations in blockchain. This goal is broke down into the following smaller goals:
- Construct representation of blockchain
- Implement basic operations, Proof of Work algorithm and Consensus algorithm
- Map endpoints to functions via Flask for testing using HTTP requests (using Postman)
The specific structure of a block in the project is:
Here each block is connected via the previous_hash
field, and the proof
field is the nouce computed by a node that solves the hashing problem.
The project includes the following parts:
blockchain.py
-- the abstract representation of our blockchain, contains fields of a blockchain and the basic operations and algorithms(e.g. Proof of Work Algorithm, Consensus Algorithm)app.py
-- all the end points in the Flask application, for running and testing the applicationserver.py
-- attempt for DNS server in the blockchain