redis init bugfix
This commit is contained in:
@@ -88,16 +88,21 @@ async def main():
|
|||||||
db_state = DbState(BlockData.by_opt('db'))
|
db_state = DbState(BlockData.by_opt('db'))
|
||||||
with db.transaction():
|
with db.transaction():
|
||||||
state = await db_state.load()
|
state = await db_state.load()
|
||||||
if state is None:
|
if state is None:
|
||||||
log.info('no state in database')
|
log.info('no state in database')
|
||||||
if redis_state:
|
if redis_state:
|
||||||
await redis_state.clear()
|
await redis_state.clear()
|
||||||
else:
|
else:
|
||||||
current_blockstate.set(state)
|
current_blockstate.set(state)
|
||||||
current_fork.set(state.root_fork)
|
current_fork.set(state.root_fork)
|
||||||
global activate_orders_needed
|
global activate_orders_needed
|
||||||
activate_orders_needed = True
|
activate_orders_needed = True
|
||||||
log.info(f'loaded state from db for root block {state.root_branch.height}')
|
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)
|
runner = BlockStateRunner(state, publish_all=publish_all if redis_state else None)
|
||||||
setup_logevent_triggers(runner)
|
setup_logevent_triggers(runner)
|
||||||
# OHLC printing hard-disabled for main. Use the finaldata process.
|
# OHLC printing hard-disabled for main. Use the finaldata process.
|
||||||
@@ -108,10 +113,6 @@ async def main():
|
|||||||
runner.on_promotion.append(db_state.finalize)
|
runner.on_promotion.append(db_state.finalize)
|
||||||
if redis_state:
|
if redis_state:
|
||||||
runner.on_head_update.append(redis_state.save)
|
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)
|
runner.on_promotion.append(finalize_transactions)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user