redis init bugfix

This commit is contained in:
tim
2024-11-01 13:32:58 -04:00
parent bc6a196bfa
commit 48fdfeeb3f

View File

@@ -88,16 +88,21 @@ async def main():
db_state = DbState(BlockData.by_opt('db'))
with db.transaction():
state = await db_state.load()
if state is None:
log.info('no state in database')
if redis_state:
await redis_state.clear()
else:
current_blockstate.set(state)
current_fork.set(state.root_fork)
global activate_orders_needed
activate_orders_needed = True
log.info(f'loaded state from db for root block {state.root_branch.height}')
if state is None:
log.info('no state in database')
if redis_state:
await redis_state.clear()
else:
current_blockstate.set(state)
current_fork.set(state.root_fork)
global activate_orders_needed
activate_orders_needed = True
log.info(f'loaded state from db for root block {state.root_branch.height}')
if redis_state:
# load initial state
log.info('initializing redis with root state')
await redis_state.save(state.root_fork, state.diffs_by_branch[state.root_branch.id])
runner = BlockStateRunner(state, publish_all=publish_all if redis_state else None)
setup_logevent_triggers(runner)
# OHLC printing hard-disabled for main. Use the finaldata process.
@@ -108,10 +113,6 @@ async def main():
runner.on_promotion.append(db_state.finalize)
if redis_state:
runner.on_head_update.append(redis_state.save)
if db:
# load initial state
log.info('initializing redis with root state')
await redis_state.save(state.root_fork, state.diffs_by_branch[state.root_branch])
runner.on_promotion.append(finalize_transactions)
try: