Spaces:
Runtime error
Runtime error
Update blockchain.py
Browse files- blockchain.py +12 -1
blockchain.py
CHANGED
|
@@ -14,6 +14,7 @@ class Blockchain:
|
|
| 14 |
main_chain=chain_load
|
| 15 |
|
| 16 |
self.pending_transactions = []
|
|
|
|
| 17 |
if load == None or load=="":
|
| 18 |
self.chain = []
|
| 19 |
self.create_block(proof=1, previous_hash='0',chain_n=create)
|
|
@@ -65,7 +66,17 @@ class Blockchain:
|
|
| 65 |
def print_previous_block(self):
|
| 66 |
return self.chain[-1]
|
| 67 |
def new_transaction(self, block):
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
self.pending_transactions.append(block)
|
| 70 |
def proof_of_work(self, previous_proof):
|
| 71 |
new_proof = 1
|
|
|
|
| 14 |
main_chain=chain_load
|
| 15 |
|
| 16 |
self.pending_transactions = []
|
| 17 |
+
self.trans_data_out = []
|
| 18 |
if load == None or load=="":
|
| 19 |
self.chain = []
|
| 20 |
self.create_block(proof=1, previous_hash='0',chain_n=create)
|
|
|
|
| 66 |
def print_previous_block(self):
|
| 67 |
return self.chain[-1]
|
| 68 |
def new_transaction(self, block):
|
| 69 |
+
trans_data = {
|
| 70 |
+
'name': block['transactions'][0]['sender'],
|
| 71 |
+
'index': block['index'],
|
| 72 |
+
'timestamp': block['timestamp'],
|
| 73 |
+
'recipient': block['transactions'][0]['recipient'],
|
| 74 |
+
'amount': block['transactions'][0]['amount'],
|
| 75 |
+
'balance': block['balance'],
|
| 76 |
+
'proof': block['proof'],
|
| 77 |
+
'previous_hash': block['previous_hash']}
|
| 78 |
+
}
|
| 79 |
+
self.trans_data_out.append(trans_data)
|
| 80 |
self.pending_transactions.append(block)
|
| 81 |
def proof_of_work(self, previous_proof):
|
| 82 |
new_proof = 1
|