mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Fixes to_dict/to_json for and some fixes
This commit is contained in:
@@ -102,7 +102,7 @@ def get_all_appointments():
|
||||
|
||||
if watcher.responder:
|
||||
for uuid, job in watcher.responder.jobs.items():
|
||||
responder_jobs[uuid] = job.to_json()
|
||||
responder_jobs[uuid] = job.to_dict()
|
||||
|
||||
response = jsonify({"watcher_appointments": watcher_appointments, "responder_jobs": responder_jobs})
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
from hashlib import sha256
|
||||
from threading import Thread
|
||||
from binascii import unhexlify
|
||||
|
||||
from pisa.logger import Logger
|
||||
@@ -29,11 +30,14 @@ class Job:
|
||||
# can be directly got from DB
|
||||
self.locator = sha256(unhexlify(dispute_txid)).hexdigest()
|
||||
|
||||
def to_json(self):
|
||||
def to_dict(self):
|
||||
job = {"locator": self.locator, "justice_rawtx": self.justice_rawtx, "appointment_end": self.appointment_end}
|
||||
|
||||
return job
|
||||
|
||||
def to_json(self):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
|
||||
class Responder:
|
||||
def __init__(self):
|
||||
@@ -62,6 +66,8 @@ class Responder:
|
||||
# TODO: Add the missing reasons (e.g. RPC_VERIFY_REJECTED)
|
||||
pass
|
||||
|
||||
return receipt
|
||||
|
||||
def create_job(self, uuid, dispute_txid, justice_txid, justice_rawtx, appointment_end, confirmations=0,
|
||||
retry=False):
|
||||
|
||||
@@ -155,7 +161,7 @@ class Responder:
|
||||
|
||||
for uuid, job in self.jobs.items():
|
||||
if job.appointment_end <= height:
|
||||
tx = Carrier.get_transaction(job.dispute_txid)
|
||||
tx = Carrier.get_transaction(job.justice_txid)
|
||||
|
||||
# FIXME: Should be improved with the librarian
|
||||
confirmations = tx.get('confirmations')
|
||||
|
||||
Reference in New Issue
Block a user