Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -238,8 +238,14 @@ def get_my_chain_send(sender_name=None):
|
|
| 238 |
except Exception as ee:
|
| 239 |
print (f'error2:: {ee}')
|
| 240 |
pass
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
message = f"Blockchain loaded from: {main_balance}{sender_name}.json"
|
| 244 |
return response,message
|
| 245 |
except Exception:
|
|
@@ -327,6 +333,34 @@ def mychain_mine_block_send(balance, chain_r=None,chain_n=None):
|
|
| 327 |
|
| 328 |
return response, show_chain,message
|
| 329 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
def mychain_mine_block_rec(balance, chain_r=None,chain_n=None):
|
| 331 |
previous_block = mychain_rec.print_previous_block()
|
| 332 |
previous_proof = previous_block['proof']
|
|
@@ -476,12 +510,17 @@ def issue_tokens(send,rec,amount):
|
|
| 476 |
|
| 477 |
|
| 478 |
mychain_send.new_transaction(f"{send}",f"{rec}",f"{amount}",f"{balance_send}")
|
|
|
|
|
|
|
| 479 |
message_send = "Transaction Added to Pool"
|
| 480 |
data_send = pd.DataFrame(mychain_send.pending_transactions)
|
| 481 |
mychain_rec.new_transaction(f"{send}",f"{rec}",f"{amount}",f"{balance_rec}")
|
| 482 |
message_rec = "Transaction Added to Pool"
|
| 483 |
data_rec = pd.DataFrame(mychain_rec.pending_transactions)
|
| 484 |
response_send, show_chain_send, message_send = mychain_mine_block_send(balance_send, chain_r=None,chain_n=send)
|
|
|
|
|
|
|
|
|
|
| 485 |
response_rec, show_chain_rec, message_rec = mychain_mine_block_rec(balance_rec, chain_r=None,chain_n=rec)
|
| 486 |
mes = (f'Send: {message_send} :: Recieve: {message_rec}')
|
| 487 |
_,rec_send=update_send_list()
|
|
|
|
| 238 |
except Exception as ee:
|
| 239 |
print (f'error2:: {ee}')
|
| 240 |
pass
|
| 241 |
+
try:
|
| 242 |
+
response_trans = {'chain': mychain_trans.chain,
|
| 243 |
+
'length': len(mychain_trans.chain)}
|
| 244 |
+
print(f'response_trans:: {response_trans}')
|
| 245 |
+
except Exception as e:
|
| 246 |
+
print (e)
|
| 247 |
+
pass
|
| 248 |
+
|
| 249 |
message = f"Blockchain loaded from: {main_balance}{sender_name}.json"
|
| 250 |
return response,message
|
| 251 |
except Exception:
|
|
|
|
| 333 |
|
| 334 |
return response, show_chain,message
|
| 335 |
|
| 336 |
+
def mychain_mine_block_trans(balance, chain_r=None,chain_n=None):
|
| 337 |
+
previous_block = mychain_trans.print_previous_block()
|
| 338 |
+
previous_proof = previous_block['proof']
|
| 339 |
+
proof = mychain_trans.proof_of_work(previous_proof)
|
| 340 |
+
previous_hash = mychain_trans.hash(previous_block)
|
| 341 |
+
block = mychain_trans.create_block(balance, proof, previous_hash,len(blockchain.chain)+1,chain_r,chain_n)
|
| 342 |
+
|
| 343 |
+
response = {'message': 'A block is MINED',
|
| 344 |
+
'index': block['index'],
|
| 345 |
+
'timestamp': block['timestamp'],
|
| 346 |
+
'balance': block['balance'],
|
| 347 |
+
'proof': block['proof'],
|
| 348 |
+
'previous_hash': block['previous_hash']
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
message = "A block is MINED"
|
| 352 |
+
show_chain = display_chain_send()
|
| 353 |
+
|
| 354 |
+
if len(mychain_trans.chain) > 1000:
|
| 355 |
+
mychain_trans.reset()
|
| 356 |
+
response = None
|
| 357 |
+
show_chain=display_chain_send()
|
| 358 |
+
message = "New Chain Created at Max 20 Blocks"
|
| 359 |
+
|
| 360 |
+
return response, show_chain,message
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
|
| 364 |
def mychain_mine_block_rec(balance, chain_r=None,chain_n=None):
|
| 365 |
previous_block = mychain_rec.print_previous_block()
|
| 366 |
previous_proof = previous_block['proof']
|
|
|
|
| 510 |
|
| 511 |
|
| 512 |
mychain_send.new_transaction(f"{send}",f"{rec}",f"{amount}",f"{balance_send}")
|
| 513 |
+
mychain_trans.new_transaction(f"{send}",f"{rec}",f"{amount}",f"{balance_send}")
|
| 514 |
+
|
| 515 |
message_send = "Transaction Added to Pool"
|
| 516 |
data_send = pd.DataFrame(mychain_send.pending_transactions)
|
| 517 |
mychain_rec.new_transaction(f"{send}",f"{rec}",f"{amount}",f"{balance_rec}")
|
| 518 |
message_rec = "Transaction Added to Pool"
|
| 519 |
data_rec = pd.DataFrame(mychain_rec.pending_transactions)
|
| 520 |
response_send, show_chain_send, message_send = mychain_mine_block_send(balance_send, chain_r=None,chain_n=send)
|
| 521 |
+
|
| 522 |
+
mychain_mine_block_trans(balance_send, chain_r=None,chain_n=send)
|
| 523 |
+
|
| 524 |
response_rec, show_chain_rec, message_rec = mychain_mine_block_rec(balance_rec, chain_r=None,chain_n=rec)
|
| 525 |
mes = (f'Send: {message_send} :: Recieve: {message_rec}')
|
| 526 |
_,rec_send=update_send_list()
|