doc/log touchups
This commit is contained in:
@@ -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)}')
|
||||
|
||||
|
||||
|
||||
@@ -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)+']'
|
||||
|
||||
Reference in New Issue
Block a user