mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
PEP8 linting
This commit is contained in:
@@ -8,6 +8,7 @@ import pisa.conf as conf
|
||||
HOST = 'localhost'
|
||||
PORT = 9814
|
||||
|
||||
|
||||
class StructuredMessage(object):
|
||||
def __init__(self, message, **kwargs):
|
||||
self.message = message
|
||||
@@ -31,4 +32,3 @@ logging.basicConfig(format='%(message)s', level=logging.INFO, handlers=[
|
||||
# TODO: Check if a long lived connection like this may create problems (timeouts)
|
||||
bitcoin_cli = AuthServiceProxy("http://%s:%s@%s:%d" % (conf.BTC_RPC_USER, conf.BTC_RPC_PASSWD, conf.BTC_RPC_HOST,
|
||||
conf.BTC_RPC_PORT))
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ def add_appointment():
|
||||
rcode = HTTP_BAD_REQUEST
|
||||
response = "appointment rejected. Request does not match the standard"
|
||||
|
||||
logging.info(M('[API] sending response and disconnecting', from_addr_port='{}:{}'.format(remote_addr, remote_port), response=response))
|
||||
logging.info(M('[API] sending response and disconnecting',
|
||||
from_addr_port='{}:{}'.format(remote_addr, remote_port), response=response))
|
||||
|
||||
return Response(response, status=rcode, mimetype='text/plain')
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ class BlockProcessor:
|
||||
justice_txid = bitcoin_cli.decoderawtransaction(justice_rawtx).get('txid')
|
||||
matches.append((locator, uuid, dispute_txid, justice_txid, justice_rawtx))
|
||||
|
||||
logging.info(M("[BlockProcessor] match found for locator.", locator=locator, uuid=uuid, justice_txid=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
|
||||
@@ -101,7 +102,8 @@ class BlockProcessor:
|
||||
else:
|
||||
missed_confirmations[tx] = 1
|
||||
|
||||
logging.info(M("[Responder] transaction missed a confirmation", tx=tx, missed_confirmations=missed_confirmations[tx]))
|
||||
logging.info(M("[Responder] transaction missed a confirmation",
|
||||
tx=tx, missed_confirmations=missed_confirmations[tx]))
|
||||
|
||||
return unconfirmed_txs, missed_confirmations
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ class Carrier:
|
||||
receipt = self.Receipt(delivered=False, reason=UNKNOWN_JSON_RPC_EXCEPTION)
|
||||
|
||||
elif errno == RPC_VERIFY_ALREADY_IN_CHAIN:
|
||||
logging.info(M("[Carrier] Transaction is already in the blockchain. Getting confirmation count", txid=txid))
|
||||
logging.info(M("[Carrier] Transaction is already in the blockchain. Getting confirmation count",
|
||||
txid=txid))
|
||||
|
||||
# If the transaction is already in the chain, we get the number of confirmations and watch the job
|
||||
# until the end of the appointment
|
||||
|
||||
@@ -18,7 +18,8 @@ class Cleaner:
|
||||
else:
|
||||
locator_uuid_map[locator].remove(uuid)
|
||||
|
||||
logging.info(M("[Cleaner] end time reached with no match! Deleting appointment.", locator=locator, uuid=uuid))
|
||||
logging.info(M("[Cleaner] end time reached with no match! Deleting appointment.",
|
||||
locator=locator, uuid=uuid))
|
||||
|
||||
@staticmethod
|
||||
def delete_completed_jobs(jobs, tx_job_map, completed_jobs, height):
|
||||
|
||||
@@ -26,8 +26,7 @@ class EncryptedBlob:
|
||||
master_key=hexlify(master_key).decode(),
|
||||
sk=hexlify(sk).decode(),
|
||||
nonce=hexlify(sk).decode(),
|
||||
encrypted_blob=self.data
|
||||
))
|
||||
encrypted_blob=self.data))
|
||||
|
||||
# Decrypt
|
||||
aesgcm = AESGCM(sk)
|
||||
|
||||
@@ -80,7 +80,8 @@ class Responder:
|
||||
if confirmations == 0:
|
||||
self.unconfirmed_txs.append(justice_txid)
|
||||
|
||||
logging.info(M("[Responder] new job added.", dispute_txid=dispute_txid, justice_txid=justice_txid, appointment_end=appointment_end))
|
||||
logging.info(M("[Responder] new job added.",
|
||||
dispute_txid=dispute_txid, justice_txid=justice_txid, appointment_end=appointment_end))
|
||||
|
||||
if self.asleep:
|
||||
self.asleep = False
|
||||
@@ -108,7 +109,8 @@ class Responder:
|
||||
txs = block.get('tx')
|
||||
height = block.get('height')
|
||||
|
||||
logging.info(M("[Responder] new block received", block_hash=block_hash, prev_block_hash=block.get('previousblockhash'), txs=txs))
|
||||
logging.info(M("[Responder] new block received",
|
||||
block_hash=block_hash, prev_block_hash=block.get('previousblockhash'), txs=txs))
|
||||
|
||||
# ToDo: #9-add-data-persistence
|
||||
# change prev_block_hash condition
|
||||
@@ -123,7 +125,8 @@ class Responder:
|
||||
|
||||
else:
|
||||
logging.warning(M("[Responder] reorg found!",
|
||||
local_prev_block_hash=prev_block_hash, remote_prev_block_hash=block.get('previousblockhash')))
|
||||
local_prev_block_hash=prev_block_hash,
|
||||
remote_prev_block_hash=block.get('previousblockhash')))
|
||||
|
||||
self.handle_reorgs()
|
||||
|
||||
@@ -170,7 +173,8 @@ class Responder:
|
||||
self.jobs[uuid].justice_rawtx, self.jobs[uuid].appointment_end, retry=True)
|
||||
|
||||
logging.warning(M("[Responder] Transaction has missed many confirmations. Rebroadcasting.",
|
||||
justice_txid=self.jobs[uuid].justice_txid, confirmations_missed=CONFIRMATIONS_BEFORE_RETRY))
|
||||
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):
|
||||
@@ -187,7 +191,9 @@ class Responder:
|
||||
# If both transactions are there, we only need to update the justice tx confirmation count
|
||||
if justice_in_chain:
|
||||
logging.info(M("[Responder] updating confirmation count for transaction.",
|
||||
justice_txid=job.justice_txid, prev_count=job.confirmations, curr_count=justice_confirmations))
|
||||
justice_txid=job.justice_txid,
|
||||
prev_count=job.confirmations,
|
||||
curr_count=justice_confirmations))
|
||||
|
||||
job.confirmations = justice_confirmations
|
||||
|
||||
|
||||
@@ -29,4 +29,5 @@ class ZMQHandler:
|
||||
block_hash = binascii.hexlify(body).decode('UTF-8')
|
||||
block_queue.put(block_hash)
|
||||
|
||||
logging.info(M("[ZMQHandler-{}] new block received via ZMQ".format(self.parent), block_hash=block_hash))
|
||||
logging.info(M("[ZMQHandler-{}] new block received via ZMQ".format(self.parent),
|
||||
block_hash=block_hash))
|
||||
|
||||
@@ -61,7 +61,8 @@ class Watcher:
|
||||
else:
|
||||
appointment_added = False
|
||||
|
||||
logging.info(M("[Watcher] maximum appointments reached, appointment rejected.", locator=appointment.locator))
|
||||
logging.info(M("[Watcher] maximum appointments reached, appointment rejected.",
|
||||
locator=appointment.locator))
|
||||
|
||||
return appointment_added
|
||||
|
||||
|
||||
Reference in New Issue
Block a user