2017-05-22 18:00:34 -07:00
|
|
|
import hashlib
|
2017-05-23 11:22:21 -07:00
|
|
|
import json
|
2017-05-22 18:00:34 -07:00
|
|
|
|
|
|
|
def sha256(secret):
|
|
|
|
preimage = secret.encode('utf8')
|
|
|
|
h = hashlib.sha256(preimage).digest()
|
|
|
|
return h
|
2017-05-22 21:57:06 -07:00
|
|
|
|
|
|
|
# TODO: Port these over to leveldb or some other database
|
|
|
|
def save_trade(trade):
|
|
|
|
with open('xcat.json', 'w') as outfile:
|
|
|
|
json.dump(trade, outfile)
|
|
|
|
|
|
|
|
def get_trade():
|
|
|
|
with open('xcat.json') as data_file:
|
|
|
|
xcatdb = json.load(data_file)
|
|
|
|
return xcatdb
|
|
|
|
|
|
|
|
def get_contract():
|
|
|
|
with open('contract.json') as data_file:
|
|
|
|
contractdb = json.load(data_file)
|
|
|
|
return contractdb
|
|
|
|
|
|
|
|
def save_contract(contracts):
|
|
|
|
with open('contract.json', 'w') as outfile:
|
|
|
|
json.dump(contracts, outfile)
|