Skip to content

Commit

Permalink
Merge pull request #19 from youwenbusi/master
Browse files Browse the repository at this point in the history
add db.ping(reconnect=True)
  • Loading branch information
yanyanho authored Aug 25, 2020
2 parents 19acd16 + 7c31917 commit f9b9304
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions commands/event_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def event_sync():
MIXERTYPE = "mixer"
mixer_addr = ""
while tag:
db.ping(reconnect=True)
cursor.execute(sqlSearchMixer, [MIXERTYPE])
resultMixer = cursor.fetchall()
db.commit()
Expand Down
3 changes: 3 additions & 0 deletions zeth/merkle_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def __init__(
def open(max_num_leaves: int, mid: int) -> sqlMerkleTree:
depth = int(math.log(max_num_leaves, 2))
sqlSearch = "select * from merkletree where MID=%s"
db.ping(reconnect=True)
cursor.execute(sqlSearch, [mid])
results = cursor.fetchall()
db.commit()
Expand All @@ -263,7 +264,9 @@ def open(max_num_leaves: int, mid: int) -> sqlMerkleTree:

def save(self, blockNumber: int, mid: int) -> None:
sqlSearch = "select * from merkletree where MID=%s"
db.ping(reconnect=True)
cursor.execute(sqlSearch, [mid])
db.commit()
results = cursor.fetchall()
if not results:
json_str = json.dumps(self.tree_data.to_json_dict())
Expand Down
4 changes: 4 additions & 0 deletions zkclientapp/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def depositBac(request) -> None:
traType = "deposit"
output_specstr = output_specs[0] + ';' + output_specs[1]
sqlInsert = "insert into transactions (traType, username, vin, vout, output_specs) values (%s, %s, %s, %s, %s);"
db.ping(reconnect=True)
cursor.execute(sqlInsert, [traType, req['username'], req['token_amount'], 0, output_specstr])
db.commit()
result['status'] = 0
Expand Down Expand Up @@ -426,6 +427,7 @@ def mixBac(request) -> None:
for out_spec in req['output_specs']:
outputstr = outputstr + out_spec + ';'
sqlInsert = "insert into transactions (traType, username, vin, vout, input_notes, output_specs) values (%s, %s, %s, %s, %s, %s);"
db.ping(reconnect=True)
cursor.execute(sqlInsert, [traType, req['username'], req['vin'], req['vout'], inputstr, outputstr])
db.commit()
result['status'] = 0
Expand Down Expand Up @@ -503,6 +505,7 @@ def getCommits(request) -> None:
def getContract(request) -> None:
result = {}
sqlSearch = "select * from contract"
db.ping(reconnect=True)
cursor.execute(sqlSearch)
results = cursor.fetchall()
db.commit()
Expand Down Expand Up @@ -542,6 +545,7 @@ def getTransactions(request) -> None:
privatekey = Account.decrypt(keytext, req['password'])
if privatekey:
sqlSearch = "select * from transactions where username = %s"
db.ping(reconnect=True)
cursor.execute(sqlSearch, [req['username']])
results = cursor.fetchall()
db.commit()
Expand Down
1 change: 1 addition & 0 deletions zkclientapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def create_table():
def deploy_contract():
print("check whether existed bac token contract and mixer contract")
sqlSearchBac = "select * from contract where conType = %s"
db.ping(reconnect=True)
cursor.execute(sqlSearchBac, [BACTYPE])
resultBac = cursor.fetchall()
db.commit()
Expand Down

0 comments on commit f9b9304

Please sign in to comment.