Skip to content

Commit

Permalink
specify start block for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlanglen committed Apr 30, 2024
1 parent e2ad39c commit b9dddc5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions indexer_app/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ async def indexer(network: str, from_block: int, to_block: int):
lake_config.aws_secret_key = settings.AWS_SECRET_ACCESS_KEY
_, streamer_messages_queue = streamer(lake_config)
block_count = 0

while True:
try:
# streamer_message is the current block
streamer_message = await streamer_messages_queue.get()
block_count += 1
await cache_block_height("current_block_height", streamer_message.block.header.height, block_count) # current block height
await cache_block_height(
"current_block_height",
streamer_message.block.header.height,
block_count,
) # current block height
await handle_streamer_message(streamer_message)
except Exception as e:
logger.error(f"Error in streamer_messages_queue: {e}")
Expand All @@ -45,16 +49,19 @@ def listen_to_near_events():

try:
# Update below with desired network & block height
start_block = get_block_height('current_block_height')
# start_block = 104_963_982
# start_block = get_block_height('current_block_height')
start_block = 105_923_501 # manually setting for debugging TODO: remove this
logger.info(f"what's the start block, pray tell? {start_block-1}")
loop.run_until_complete(indexer("mainnet", start_block-1, None))
loop.run_until_complete(indexer("mainnet", start_block - 1, None))
finally:
loop.close()


from celery.signals import task_revoked


@task_revoked.connect
def on_task_revoked(request, terminated, signum, expired, **kwargs):
logger.info(f"Task {request.id} revoked; terminated={terminated}, signum={signum}, expired={expired}")
logger.info(
f"Task {request.id} revoked; terminated={terminated}, signum={signum}, expired={expired}"
)

0 comments on commit b9dddc5

Please sign in to comment.