Skip to content

Commit

Permalink
remove hardcoded appdata table
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang committed Jul 2, 2024
1 parent 4e1303e commit 4cd399f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sync/app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

log = set_log(__name__)


SYNC_TABLE = SyncTable.APP_DATA


class AppDataHandler(RecordHandler): # pylint:disable=too-many-instance-attributes
"""
This class is responsible for consuming new dune records and missing values from previous runs
Expand All @@ -35,8 +31,9 @@ def __init__( # pylint:disable=too-many-arguments
config: SyncConfig,
ipfs_access_key: str,
missing_file_name: str,
sync_table
):
super().__init__(block_range, SYNC_TABLE, config)
super().__init__(block_range, sync_table, config)
self.file_manager = file_manager
self.ipfs_access_key = ipfs_access_key

Expand Down Expand Up @@ -132,29 +129,32 @@ async def sync_app_data( # pylint: disable=too-many-arguments
) -> None:
"""App Data Sync Logic"""

sync_table = SyncTable.APP_DATA_GNOSIS
genesis_bl = 15310317
if chain == "mainnet":
genesis_bl = 12153262
sync_table = SyncTable.APP_DATA

block_range = BlockRange(
block_from=last_sync_block(
aws,
table=SYNC_TABLE,
table=sync_table,
genesis_block=genesis_bl, # First App Hash Block
),
block_to=await dune.latest_app_hash_block(chain),
)

data_handler = AppDataHandler(
file_manager=FileIO(config.volume_path / str(SYNC_TABLE)),
file_manager=FileIO(config.volume_path / str(sync_table)),
new_rows=await dune.get_app_hashes(block_range, chain),
block_range=block_range,
config=config,
ipfs_access_key=ipfs_access_key,
missing_file_name=config.missing_files_name,
sync_table=sync_table
)
await data_handler.fetch_content_and_filter(
max_retries=config.max_retries, give_up_threshold=config.give_up_threshold
)
UploadHandler(aws, data_handler, table=SYNC_TABLE).write_and_upload_content(dry_run)
UploadHandler(aws, data_handler, table=sync_table).write_and_upload_content(dry_run)
log.info("app_data sync run completed successfully")

0 comments on commit 4cd399f

Please sign in to comment.