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