Created
January 20, 2022 19:44
-
-
Save mohitkh7/c6e7839a24963d7323d47bc7dbadf012 to your computer and use it in GitHub Desktop.
Skeleton code for scipy 2021 blockchain workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
class Blockchain(): | |
def __init__(self): | |
self.chain = [] | |
self.current_transactions = [] | |
def new_block(self): | |
# Creates a new Block and adds it to the chain | |
pass | |
def new_transaction(self): | |
# Adds a new transaction to the list of transactions | |
pass | |
@staticmethod | |
def hash(block): | |
# Hashes a Block | |
pass | |
@property | |
def last_block(self): | |
# Returns the last Block in the chain | |
pass | |
def proof_of_work(self): | |
# Simple proof of work algorithm | |
pass | |
@staticmethod | |
def validate_nonce(): | |
# Checks whether computed nonce is valid or not | |
pass | |
# Create flask application | |
app = Flask(__name__) | |
@app.route('/chain') | |
def display_chain(): | |
return "Displays full blockchain" | |
@app.route('/transaction') | |
def add_new_transaction(): | |
return "Add a new transaction" | |
@app.route('/mine') | |
def mine_new_block(): | |
return "Mines a new block" | |
if __name__ == "__main__": | |
# Run the flask web server | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment