-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblockchain_template.py
76 lines (38 loc) · 1.13 KB
/
blockchain_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class Blockchain:
def __init__(self):
def new_block(self, proof, previous_hash):
block = {
'index': ,
'timestamp': ,
'transactions': ,
'proof': ,
'previous_hash': ,
}
def register_node(self, address):
def valid_chain(self, chain):
def resolve_conflicts(self):
def new_transaction(self, sender, recipient, amount):
{
'sender': sender,
'recipient': recipient,
'amount': amount,
}
def last_block(self):
def hash(block):
def proof_of_work(self, last_block):
def valid_proof(last_proof, proof, last_hash):
app = Flask(__name__)
node_identifier = #Big unique number
blockchain = Blockchain()
@app.route('/mine', methods=['GET'])
def mine():
@app.route('/transactions/new', methods=['POST'])
def new_transaction():
@app.route('/chain', methods=['GET'])
def full_chain():
@app.route('/nodes/register', methods=['POST'])
def register_nodes():
@app.route('/nodes/resolve', methods=['GET'])
def consensus():
if __name__ == '__main__':
app.run()