Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -257,6 +257,26 @@ def display_chain_rec():
|
|
257 |
response = {'chain': mychain_rec.chain,
|
258 |
'length': len(mychain_rec.chain)}
|
259 |
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
|
262 |
def mychain_mine_block_send(balance, chain_r=None,chain_n=None):
|
@@ -373,28 +393,34 @@ def issue_tokens(send,rec,amount):
|
|
373 |
mes = f"Sender has no wallet {e}"
|
374 |
pass
|
375 |
if p==True:
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
balance = 0
|
380 |
-
p=False
|
381 |
-
print (balance)
|
382 |
-
balance_send =int(balance)-int(amount)
|
383 |
-
if balance_send >=0:
|
384 |
-
p=True
|
385 |
-
response,message = get_my_chain_rec(rec)
|
386 |
-
lod_rec = response
|
387 |
-
print (lod_rec)
|
388 |
try:
|
389 |
-
balance =
|
390 |
-
print (balance)
|
391 |
except Exception:
|
392 |
-
p=False
|
393 |
balance = 0
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
p = False
|
399 |
if z==False:
|
400 |
mes = "Invalid Blockchain"
|
|
|
257 |
response = {'chain': mychain_rec.chain,
|
258 |
'length': len(mychain_rec.chain)}
|
259 |
return response
|
260 |
+
|
261 |
+
def valid_send():
|
262 |
+
valid,ind,mes = mychain_send.chain_valid(mychain_send.chain)
|
263 |
+
if valid:
|
264 |
+
response = 'The Blockchain is valid.'
|
265 |
+
z=True
|
266 |
+
else:
|
267 |
+
response = f'Blockchain is not valid. {mes} at Index {ind}'
|
268 |
+
z=False
|
269 |
+
return response,z
|
270 |
+
def valid_rec():
|
271 |
+
valid,ind,mes = mychain_rec.chain_valid(mychain_rec.chain)
|
272 |
+
if valid:
|
273 |
+
response = 'The Blockchain is valid.'
|
274 |
+
z=True
|
275 |
+
else:
|
276 |
+
response = f'Blockchain is not valid. {mes} at Index {ind}'
|
277 |
+
z=False
|
278 |
+
return response,z
|
279 |
+
|
280 |
|
281 |
|
282 |
def mychain_mine_block_send(balance, chain_r=None,chain_n=None):
|
|
|
393 |
mes = f"Sender has no wallet {e}"
|
394 |
pass
|
395 |
if p==True:
|
396 |
+
|
397 |
+
mes,val = valid_send()
|
398 |
+
if val == True:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
try:
|
400 |
+
balance = lod["chain"][-1]["balance"]
|
|
|
401 |
except Exception:
|
|
|
402 |
balance = 0
|
403 |
+
p=False
|
404 |
+
print (balance)
|
405 |
+
balance_send =int(balance)-int(amount)
|
406 |
+
if balance_send >=0:
|
407 |
+
p=True
|
408 |
+
response,message = get_my_chain_rec(rec)
|
409 |
+
lod_rec = response
|
410 |
+
print (lod_rec)
|
411 |
+
try:
|
412 |
+
balance = lod_rec["chain"][-1]["balance"]
|
413 |
+
print (balance)
|
414 |
+
except Exception:
|
415 |
+
p=False
|
416 |
+
balance = 0
|
417 |
+
balance_rec =int(balance)+int(amount)
|
418 |
+
|
419 |
+
if balance_send < 0:
|
420 |
+
mes ="Not enough tokens"
|
421 |
+
p = False
|
422 |
+
if val == False:
|
423 |
+
mes = mes
|
424 |
p = False
|
425 |
if z==False:
|
426 |
mes = "Invalid Blockchain"
|