mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Changed log format to JSON; fixed missing return value in get_potential_matches
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import binascii
|
||||
from hashlib import sha256
|
||||
|
||||
from pisa import logging, bitcoin_cli
|
||||
from pisa import logging, bitcoin_cli, M
|
||||
from pisa.utils.auth_proxy import JSONRPCException
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class BlockProcessor:
|
||||
|
||||
except JSONRPCException as e:
|
||||
block = None
|
||||
logging.error("[BlockProcessor] couldn't get block from bitcoind. Error code {}".format(e))
|
||||
logging.error(M("[BlockProcessor] couldn't get block from bitcoind.", error_code=e))
|
||||
|
||||
return block
|
||||
|
||||
@@ -26,7 +26,7 @@ class BlockProcessor:
|
||||
|
||||
except JSONRPCException as e:
|
||||
block_hash = None
|
||||
logging.error("[BlockProcessor] couldn't get block hash. Error code {}".format(e))
|
||||
logging.error(M("[BlockProcessor] couldn't get block hash.", error_code=e))
|
||||
|
||||
return block_hash
|
||||
|
||||
@@ -54,10 +54,12 @@ class BlockProcessor:
|
||||
potential_matches = {locator: potential_locators[locator] for locator in intersection}
|
||||
|
||||
if len(potential_matches) > 0:
|
||||
logging.info("[BlockProcessor] list of potential matches: {}".format(potential_matches))
|
||||
logging.info(M("[BlockProcessor] list of potential matches", potential_matches=potential_matches))
|
||||
|
||||
else:
|
||||
logging.info("[BlockProcessor] no potential matches found")
|
||||
logging.info(M("[BlockProcessor] no potential matches found"))
|
||||
|
||||
return potential_matches
|
||||
|
||||
return potential_matches
|
||||
|
||||
@@ -73,13 +75,12 @@ class BlockProcessor:
|
||||
justice_txid = bitcoin_cli.decoderawtransaction(justice_rawtx).get('txid')
|
||||
matches.append((locator, uuid, dispute_txid, justice_txid, justice_rawtx))
|
||||
|
||||
logging.info("[BlockProcessor] match found for locator {} (uuid: {}): {}".format(
|
||||
locator, uuid, justice_txid))
|
||||
logging.info(M("[BlockProcessor] match found for locator.", locator=locator, uuid=uuid, justice_txid=justice_txid))
|
||||
|
||||
except JSONRPCException as e:
|
||||
# Tx decode failed returns error code -22, maybe we should be more strict here. Leaving it simple
|
||||
# for the POC
|
||||
logging.error("[BlockProcessor] can't build transaction from decoded data. Error code {}".format(e))
|
||||
logging.error(M("[BlockProcessor] can't build transaction from decoded data.", error_code=e))
|
||||
|
||||
return matches
|
||||
|
||||
@@ -91,7 +92,7 @@ class BlockProcessor:
|
||||
if tx in tx_job_map and tx in unconfirmed_txs:
|
||||
unconfirmed_txs.remove(tx)
|
||||
|
||||
logging.info("[Responder] confirmation received for tx {}".format(tx))
|
||||
logging.info(M("[Responder] confirmation received for transaction", tx=tx))
|
||||
|
||||
elif tx in unconfirmed_txs:
|
||||
if tx in missed_confirmations:
|
||||
@@ -100,8 +101,7 @@ class BlockProcessor:
|
||||
else:
|
||||
missed_confirmations[tx] = 1
|
||||
|
||||
logging.info("[Responder] tx {} missed a confirmation (total missed: {})"
|
||||
.format(tx, missed_confirmations[tx]))
|
||||
logging.info(M("[Responder] transaction missed a confirmation", tx=tx, missed_confirmations=missed_confirmations[tx]))
|
||||
|
||||
return unconfirmed_txs, missed_confirmations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user