diff --git a/otsserver/backup.py b/otsserver/backup.py index c8f835c..a1321b1 100644 --- a/otsserver/backup.py +++ b/otsserver/backup.py @@ -298,7 +298,7 @@ def loop(self): # the following raise an exception and block computation if the attestation does not verify attested_time = attestation.verify_against_blockheader(key, block_header) logging.debug("Verifying " + b2x(key) + " result " + str(attested_time)) - break; + break except Exception as err: logging.info("%s - error contacting bitcoin node, sleeping..." % (err)) time.sleep(SLEEP_SECS) @@ -333,8 +333,3 @@ def loop(self): elapsed_time = time.time() - start_time logging.info("Took %ds for %s" % (elapsed_time, str(backup_url))) - - - - - diff --git a/otsserver/calendar.py b/otsserver/calendar.py index 8887983..4bde052 100644 --- a/otsserver/calendar.py +++ b/otsserver/calendar.py @@ -198,11 +198,11 @@ def add_timestamps(self, new_timestamps): if n % 10000 == 0: now = time.time() logging.debug("Added %d timestamps to LevelDB; %f stamps/second" % - (n, 10000.0 / (now - last))) + (n, 10000.0 / (now - last))) last = now del batch_cache - self.db.Write(batch, sync = True) + self.db.Write(batch, sync=True) logging.debug("Done LevelDbCalendar.add_timestamps(), added %d timestamps total" % n) class Calendar: diff --git a/otsserver/rpc.py b/otsserver/rpc.py index 101239b..0a36eab 100644 --- a/otsserver/rpc.py +++ b/otsserver/rpc.py @@ -206,7 +206,7 @@ def do_GET(self): a_week_ago = (datetime.date.today() - datetime.timedelta(days=7)).timetuple() a_week_ago_posix = time.mktime(a_week_ago) transactions_in_last_week = list(filter(lambda x: x["time"] > a_week_ago_posix, transactions)) - fees_in_last_week = reduce(lambda a,b: a-b["fee"], transactions_in_last_week, 0) + fees_in_last_week = reduce(lambda a, b: a-b["fee"], transactions_in_last_week, 0) try: time_between_transactions = str(round(168 / len(transactions_in_last_week), 2)) # in hours based on 168 hours in a week time_between_transactions += " hours" diff --git a/otsserver/stamper.py b/otsserver/stamper.py index 018b7c0..3393836 100644 --- a/otsserver/stamper.py +++ b/otsserver/stamper.py @@ -42,7 +42,7 @@ def make_btc_block_merkle_tree(blk_txids): digests.append(digests[-1].msg) next_level = [] - for i in range(0,len(digests), 2): + for i in range(0, len(digests), 2): next_level.append(cat_sha256d(digests[i], digests[i + 1])) digests = next_level @@ -182,7 +182,7 @@ def sort_filter_unspent(unspent): return sorted(filter(lambda x: x['amount'] > DUST and x['spendable'], unspent), key=lambda x: x['amount']) - unspent = sort_filter_unspent(listunspent(proxy,1)) + unspent = sort_filter_unspent(listunspent(proxy, 1)) if len(unspent): return unspent @@ -392,7 +392,7 @@ def __do_bitcoin(self): return change_addr = proxy._call("getnewaddress", "", "bech32") - change_addr_info = proxy._call("getaddressinfo",change_addr) + change_addr_info = proxy._call("getaddressinfo", change_addr) change_addr_script = x(change_addr_info['scriptPubKey']) prev_tx = self.__create_new_timestamp_tx_template(unspent[-1]['outpoint'], unspent[-1]['amount'], @@ -540,8 +540,7 @@ def is_pending(self, commitment): return "Timestamped by transaction %s; waiting for %d confirmations"\ % (b2lx(ttx.tx.GetTxid()), self.min_confirmations-1) - else: - return False + return False def __init__(self, calendar, exit_event, relay_feerate, min_confirmations, min_tx_interval, max_fee, max_pending): self.calendar = calendar