Check for exist json databases

main
justuser31 1 year ago
parent 80befe89a1
commit f8b1a808cf

@ -1,9 +1,13 @@
import json import json
from os.path import isfile
from os import system as sys
# Money # Money
# {username: balance} # {username: balance, ...}
class money(): class money():
def read(): def read():
if not isfile("money.json"):
sys('echo "{}" > money.json')
with open('money.json', 'r') as openfile: with open('money.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data
@ -14,9 +18,11 @@ class money():
# Mining + Registrations # Mining + Registrations
# Hash is encrypted! # Hash is encrypted!
# [ {"PrevHash": "00043dsafd", "nonce": 1, "OpenKey": "762eagdfgtars5e34"}, ...] # [ {"PrevHash": "00043dsafd", "nonce": 1,"date": , "OpenKey": "762eagdfgtars5e34"}, ...]
class mine(): class mine():
def read(): def read():
if not isfile("mine.json"):
sys('echo "[]" > mine.json')
with open('mine.json', 'r') as openfile: with open('mine.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data
@ -30,6 +36,8 @@ class mine():
# [ {"Payer": "user32532", "Receiver": "user64582", "OpenKey": "762eagdfgtars5e34", "PrevHash": "fsd2675ads"} , ...] # [ {"Payer": "user32532", "Receiver": "user64582", "OpenKey": "762eagdfgtars5e34", "PrevHash": "fsd2675ads"} , ...]
class pay(): class pay():
def read(): def read():
if not isfile("pay.json"):
sys('echo "[]" > pay.json')
with open('pay.json', 'r') as openfile: with open('pay.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data
@ -42,6 +50,8 @@ class pay():
# {"user32532": "762eagdfgtars5e34", ...} # {"user32532": "762eagdfgtars5e34", ...}
class keys(): class keys():
def read(): def read():
if not isfile("keys.json"):
sys('echo "{}" > keys.json')
with open('keys.json', 'r') as openfile: with open('keys.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data

Loading…
Cancel
Save