Skip to content

Commit

Permalink
fix: pre-commit formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth-Schmidt committed Apr 10, 2024
1 parent ebdcd5e commit 8e5754a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 3 additions & 4 deletions snapshotter/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
from snapshotter.utils.default_logger import logger
from snapshotter.utils.file_utils import read_json_file
from snapshotter.utils.models.data_models import SnapshotterEpochProcessingReportItem
from snapshotter.utils.models.data_models import SnapshotterStates
from snapshotter.utils.models.data_models import SnapshotterStateUpdate
from snapshotter.utils.models.data_models import SnapshotterIssue
from snapshotter.utils.models.data_models import SnapshotterReportState
from snapshotter.utils.models.data_models import SnapshotterStates
from snapshotter.utils.models.data_models import SnapshotterStateUpdate
from snapshotter.utils.models.data_models import TaskStatusRequest
from snapshotter.utils.models.data_models import UnfinalizedProject
from snapshotter.utils.redis.rate_limiter import load_rate_limiter_scripts
Expand All @@ -51,7 +51,6 @@
from snapshotter.utils.redis.redis_keys import project_last_finalized_epoch_key
from snapshotter.utils.rpc import RpcHelper


REDIS_CONN_CONF = {
'host': settings.redis.host,
'port': settings.redis.port,
Expand Down Expand Up @@ -158,7 +157,7 @@ async def health_check(
'status': 'error',
'message': 'Snapshotter is not active',
}

# check if there are any unfinalized projects every 10 minutes
if int(time.time()) - app.state.last_unfinalized_check >= 600:
app.state.last_unfinalized_check = int(time.time())
Expand Down
13 changes: 7 additions & 6 deletions snapshotter/utils/data_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import json
import os
from typing import List
from random import sample
from typing import List

import tenacity
from ipfs_client.dag import IPFSAsyncClientError
Expand Down Expand Up @@ -834,11 +834,12 @@ async def get_project_time_series_data(
project_ids=project_ids,
)


async def snapshotter_last_finalized_check(
redis_conn: aioredis.Redis,
state_contract_obj,
rpc_helper,
):
):
try:
# get all projects from redis
all_projects = await redis_conn.smembers(stored_projects_key())
Expand All @@ -850,7 +851,7 @@ async def snapshotter_last_finalized_check(
# get current epoch and the last finalized snapshot for each sampled project
tasks = [state_contract_obj.functions.currentEpoch()]
tasks += [
state_contract_obj.functions.lastFinalizedSnapshot(project_id)
state_contract_obj.functions.lastFinalizedSnapshot(project_id)
for project_id in samples
]

Expand All @@ -868,9 +869,9 @@ async def snapshotter_last_finalized_check(
lastFinalizedEpochId=last_finalized_snapshot,
)
unfinalized_projects.append(unfinalized_project)

return unfinalized_projects

except Exception as e:
logger.warning('Error while checking for unfinalized snapshots', error=e)
return []
return []
1 change: 1 addition & 0 deletions snapshotter/utils/models/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class TaskStatusRequest(BaseModel):
task_type: str
wallet_address: str


class UnfinalizedProject(BaseModel):
projectId: str
currentEpochId: int
Expand Down

0 comments on commit 8e5754a

Please sign in to comment.