From ed0fcd4454dab0ef10a6a34315649de1b788b3eb Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 17 Feb 2024 15:42:08 -0400 Subject: [PATCH] doc/log touchups --- src/dexorder/bin/backfill_ohlc.py | 3 --- src/dexorder/ohlc.py | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dexorder/bin/backfill_ohlc.py b/src/dexorder/bin/backfill_ohlc.py index 2b3af1b..62f54ca 100644 --- a/src/dexorder/bin/backfill_ohlc.py +++ b/src/dexorder/bin/backfill_ohlc.py @@ -24,10 +24,7 @@ log = logging.getLogger('dexorder.backfill') def finalize_callback(block: Block, diffs: Reversible[Union[DiffItem, DiffEntryItem]]): - # start = now() - log.info("finalizing OHLC's") ohlc_save(block, diffs) - # log.info(f'\ttook {(now() - start).total_seconds():.1f} seconds') log.info(f'backfill completed through block {block.height} {from_timestamp(block.timestamp):%Y-%m-%d %H:%M:%S} {hexstr(block.hash)}') diff --git a/src/dexorder/ohlc.py b/src/dexorder/ohlc.py index 9c937f6..c0a0463 100644 --- a/src/dexorder/ohlc.py +++ b/src/dexorder/ohlc.py @@ -6,7 +6,7 @@ from typing import Optional, NamedTuple, Reversible, Union from cachetools import LFUCache -from dexorder import dec, config, from_timestamp, timestamp +from dexorder import dec, config, from_timestamp, timestamp, now from dexorder.base.chain import current_chain from dexorder.blockstate import BlockDict, DiffItem, current_blockstate from dexorder.blockstate.diff import DiffEntryItem @@ -331,14 +331,20 @@ def ohlc_save(_block: Block, diffs: Reversible[Union[DiffItem, DiffEntryItem]]): """ used as a finalization callback from BlockState data. """ + start = now() + log.info("finalizing OHLC's") dirty = False for diff in diffs: if diff.series == 'ohlc': symbol, period = diff.key ohlcs.save_all(symbol, period, diff.value) dirty = True + log.info(f'\ttook {(now() - start).total_seconds():.1f} seconds') + start = now() + log.info("flushing OHLC's") if dirty: ohlcs.flush() + log.info(f'\ttook {(now() - start).total_seconds():.1f} seconds') def ohlc_value_to_string(bars: list[NativeOHLC]): return '['+','.join(b.json for b in bars)+']'