Omnibus commited on
Commit
e02f6b7
·
1 Parent(s): 8283c59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -51
app.py CHANGED
@@ -144,23 +144,11 @@ def get_chain(repo_name=None,chain_name=None,token=None):
144
  repo_name = repo_d
145
  if chain_name=="":
146
  chain_name = chain_d
147
- #src = f"https://huggingface.co/spaces/{repo_name}/raw/main/{chain_name}"
148
-
149
- #ff = open('chain1.json','r')
150
- #src = ff.read()
151
- #src = json.loads(ff)
152
-
153
-
154
  try:
155
  r = requests.get(f'{main_chain}{chain_name}')
156
  #create_chain(load=r.text)
157
  global blockchain
158
  blockchain = Blockchain(chain_load=main_chain,load=r.text)
159
- #return "New Chain Created",display_chain()
160
-
161
-
162
-
163
- #create_chain(src)
164
  response = {'chain': blockchain.chain,
165
  'length': len(blockchain.chain)}
166
  message = f"Blockchain loaded from: {main_chain}{chain_name}"
@@ -211,14 +199,7 @@ def add_node(this_space,repo,space,chain_file):
211
  repo = main_balance.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[0]
212
  name = main_balance.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[1]
213
 
214
- f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="dataset"))
215
- send_list =[]
216
- for i,ea in enumerate(f_ist):
217
- if "balance/" in ea:
218
- try:
219
- send_list.append(ea.split("/",1)[1].split(".",1)[0])
220
- except Exception:
221
- pass
222
 
223
 
224
  ############################## BLOCKCHAIN END ###############################
@@ -357,41 +338,23 @@ def issue_tokens(send,rec,amount):
357
  pass
358
  if p==True:
359
  try:
360
- #if lod["chain"][-1]["index"] > 1:
361
  balance = lod["chain"][-1]["balance"]
362
- #if lod["chain"][-1]["index"] == 1:
363
- # balance = 0
364
  except Exception:
365
-
366
  balance = 0
367
  p=False
368
  print (balance)
369
-
370
  balance_send =int(balance)-int(amount)
371
  if balance_send >=0:
372
  p=True
373
-
374
  response,message = get_my_chain_rec(rec)
375
- #lod_rec = json.loads(response)
376
  lod_rec = response
377
  print (lod_rec)
378
  try:
379
- #if lod_rec["chain"][-1]["index"] > 1:
380
  balance = lod_rec["chain"][-1]["balance"]
381
  print (balance)
382
- #if lod_rec["chain"][-1]["index"] == 1:
383
- # balance = 0
384
  except Exception:
385
  p=False
386
  balance = 0
387
- #try:
388
- # if lod_rec["chain"][0]["index"] > 1:
389
- # balance = lod_rec[0]["balance"]
390
- # if lod_rec["chain"][0]["index"] == 1:
391
- # balance = 0
392
- # p=True
393
- #except Exception:
394
- # p=False
395
  balance_rec =int(balance)+int(amount)
396
 
397
  if balance_send < 0:
@@ -416,7 +379,6 @@ def issue_tokens(send,rec,amount):
416
  response_rec, show_chain_rec, message_rec = mychain_mine_block_rec(balance_rec, chain_r=None,chain_n=rec)
417
  mes = (f'Send: {message_send} :: Recieve: {message_rec}')
418
  return (mes, p, response_send, response_rec, show_chain_send, show_chain_rec, data_send, data_rec, message_send, message_rec)
419
- #return (mes, p, response_send)
420
  ############################## MYCHAIN END ###############################
421
 
422
  def res_source():
@@ -444,15 +406,6 @@ def res_source():
444
  return "__Source__ Reset"
445
  except Exception as e:
446
  return e
447
-
448
- f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="dataset"))
449
- send_list =[]
450
- for i,ea in enumerate(f_ist):
451
- if "balance/" in ea:
452
- try:
453
- send_list.append(ea.split("/",1)[1].split(".",1)[0])
454
- except Exception:
455
- pass
456
 
457
  with gr.Blocks() as bc:
458
  with gr.Row(visible=True) as invalid:
@@ -493,9 +446,9 @@ with gr.Blocks() as bc:
493
  node_file=gr.Textbox(label="Node File")
494
  node_add=gr.Button("Add Node")
495
  with gr.Accordion("Tokens", open=False):
496
-
497
- issue_btn=gr.Button()
498
- reset_source=gr.Button()
499
  out_box_bool=gr.Textbox()
500
  with gr.Row():
501
  with gr.Column():
 
144
  repo_name = repo_d
145
  if chain_name=="":
146
  chain_name = chain_d
 
 
 
 
 
 
 
147
  try:
148
  r = requests.get(f'{main_chain}{chain_name}')
149
  #create_chain(load=r.text)
150
  global blockchain
151
  blockchain = Blockchain(chain_load=main_chain,load=r.text)
 
 
 
 
 
152
  response = {'chain': blockchain.chain,
153
  'length': len(blockchain.chain)}
154
  message = f"Blockchain loaded from: {main_chain}{chain_name}"
 
199
  repo = main_balance.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[0]
200
  name = main_balance.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[1]
201
 
202
+
 
 
 
 
 
 
 
203
 
204
 
205
  ############################## BLOCKCHAIN END ###############################
 
338
  pass
339
  if p==True:
340
  try:
 
341
  balance = lod["chain"][-1]["balance"]
 
 
342
  except Exception:
 
343
  balance = 0
344
  p=False
345
  print (balance)
 
346
  balance_send =int(balance)-int(amount)
347
  if balance_send >=0:
348
  p=True
 
349
  response,message = get_my_chain_rec(rec)
 
350
  lod_rec = response
351
  print (lod_rec)
352
  try:
 
353
  balance = lod_rec["chain"][-1]["balance"]
354
  print (balance)
 
 
355
  except Exception:
356
  p=False
357
  balance = 0
 
 
 
 
 
 
 
 
358
  balance_rec =int(balance)+int(amount)
359
 
360
  if balance_send < 0:
 
379
  response_rec, show_chain_rec, message_rec = mychain_mine_block_rec(balance_rec, chain_r=None,chain_n=rec)
380
  mes = (f'Send: {message_send} :: Recieve: {message_rec}')
381
  return (mes, p, response_send, response_rec, show_chain_send, show_chain_rec, data_send, data_rec, message_send, message_rec)
 
382
  ############################## MYCHAIN END ###############################
383
 
384
  def res_source():
 
406
  return "__Source__ Reset"
407
  except Exception as e:
408
  return e
 
 
 
 
 
 
 
 
 
409
 
410
  with gr.Blocks() as bc:
411
  with gr.Row(visible=True) as invalid:
 
446
  node_file=gr.Textbox(label="Node File")
447
  node_add=gr.Button("Add Node")
448
  with gr.Accordion("Tokens", open=False):
449
+ with gr.Row():
450
+ issue_btn=gr.Button()
451
+ reset_source=gr.Button("Reset")
452
  out_box_bool=gr.Textbox()
453
  with gr.Row():
454
  with gr.Column():