Fixes from PR review

This commit is contained in:
Salvatore Ingala
2019-10-10 10:34:03 +07:00
parent 831545ef2c
commit aea1d1f1e0
11 changed files with 43 additions and 44 deletions

View File

@@ -47,7 +47,7 @@ class Responder:
def add_response(self, uuid, dispute_txid, justice_txid, justice_rawtx, appointment_end, retry=False):
if self.asleep:
logger.info("waking up!")
logger.info("Waking up")
carrier = Carrier()
receipt = carrier.send_transaction(justice_rawtx, justice_txid)
@@ -82,7 +82,7 @@ class Responder:
if confirmations == 0:
self.unconfirmed_txs.append(justice_txid)
logger.info("new job added.",
logger.info("New job added.",
dispute_txid=dispute_txid, justice_txid=justice_txid, appointment_end=appointment_end)
if self.asleep:
@@ -111,7 +111,7 @@ class Responder:
txs = block.get('tx')
height = block.get('height')
logger.info("new block received",
logger.info("New block received",
block_hash=block_hash, prev_block_hash=block.get('previousblockhash'), txs=txs)
# ToDo: #9-add-data-persistence
@@ -126,9 +126,9 @@ class Responder:
self.rebroadcast(txs_to_rebroadcast)
else:
logger.warning("reorg found!",
local_prev_block_hash=prev_block_hash,
remote_prev_block_hash=block.get('previousblockhash'))
logger.warn("Reorg found",
local_prev_block_hash=prev_block_hash,
remote_prev_block_hash=block.get('previousblockhash'))
self.handle_reorgs()
@@ -138,7 +138,7 @@ class Responder:
self.asleep = True
self.zmq_subscriber.terminate = True
logger.info("no more pending jobs, going back to sleep")
logger.info("No more pending jobs, going back to sleep")
def get_txs_to_rebroadcast(self, txs):
txs_to_rebroadcast = []
@@ -174,25 +174,25 @@ class Responder:
self.add_response(uuid, self.jobs[uuid].dispute_txid, self.jobs[uuid].justice_txid,
self.jobs[uuid].justice_rawtx, self.jobs[uuid].appointment_end, retry=True)
logger.warning("Transaction has missed many confirmations. Rebroadcasting.",
justice_txid=self.jobs[uuid].justice_txid,
confirmations_missed=CONFIRMATIONS_BEFORE_RETRY)
logger.warn("Transaction has missed many confirmations. Rebroadcasting.",
justice_txid=self.jobs[uuid].justice_txid,
confirmations_missed=CONFIRMATIONS_BEFORE_RETRY)
# FIXME: Legacy code, must be checked and updated/fixed
def handle_reorgs(self):
for uuid, job in self.jobs.items():
# First we check if the dispute transaction is still in the blockchain. If not, the justice can not be
# there either, so we'll need to call the reorg manager straight away
dispute_in_chain, _ = check_tx_in_chain(job.dispute_txid, logger=logger, tx_label='dispute tx')
dispute_in_chain, _ = check_tx_in_chain(job.dispute_txid, logger=logger, tx_label='Dispute tx')
# If the dispute is there, we can check the justice tx
if dispute_in_chain:
justice_in_chain, justice_confirmations = check_tx_in_chain(job.justice_txid, logger=logger,
tx_label='justice tx')
tx_label='Justice tx')
# If both transactions are there, we only need to update the justice tx confirmation count
if justice_in_chain:
logger.info("updating confirmation count for transaction.",
logger.info("Updating confirmation count for transaction.",
justice_txid=job.justice_txid,
prev_count=job.confirmations,
curr_count=justice_confirmations)
@@ -210,5 +210,5 @@ class Responder:
# ToDo: #24-properly-handle-reorgs
# FIXME: if the dispute is not on chain (either in mempool or not there at all), we need to call the
# reorg manager
logger.warning("dispute and justice transaction missing. Calling the reorg manager")
logger.error("reorg manager not yet implemented")
logger.warn("Dispute and justice transaction missing. Calling the reorg manager")
logger.error("Reorg manager not yet implemented")