From 171f20ed07c3e8ada257d97dbd123e50f39d9dd1 Mon Sep 17 00:00:00 2001 From: Kaqtus14 Date: Mon, 30 Aug 2021 18:16:30 +0200 Subject: [PATCH 1/2] Indent transactions --- simpleCoin/wallet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/simpleCoin/wallet.py b/simpleCoin/wallet.py index 859ba03..530530e 100644 --- a/simpleCoin/wallet.py +++ b/simpleCoin/wallet.py @@ -22,6 +22,7 @@ import time import base64 import ecdsa +import json def wallet(): @@ -92,11 +93,11 @@ def check_transactions(): """ try: res = requests.get('http://localhost:5000/blocks') - print(res.text) + print(json.dumps(res.json(),indent=2)) except requests.ConnectionError: print('Connection error. Make sure that you have run miner.py in another terminal.') - + def generate_ECDSA_keys(): """This function takes care of creating your private and public (your address) keys. From 856a38135230993a9ba3cdbf0e6fb49c6938cee9 Mon Sep 17 00:00:00 2001 From: Kaqtus <62554049+Kaqtus14@users.noreply.github.com> Date: Sun, 19 Sep 2021 17:50:35 +0200 Subject: [PATCH 2/2] Validate blockchain --- simpleCoin/miner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/simpleCoin/miner.py b/simpleCoin/miner.py index 3532eaa..491b925 100644 --- a/simpleCoin/miner.py +++ b/simpleCoin/miner.py @@ -174,9 +174,14 @@ def consensus(blockchain): def validate_blockchain(block): - """Validate the submitted chain. If hashes are not correct, return false + """Validate the submitted chain. If hashes are not correct, return False block(str): json """ + + for i in range(len(block)-1): + if not block[i].hash_block() == block[i+1].previous_hash: + return False + return True