Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network info in config #485

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ class AccountingConfig:
buffer_accounting_config: BufferAccountingConfig
io_config: IOConfig
data_processing_config: DataProcessingConfig
network: Network

@staticmethod
def from_network(network: Network) -> AccountingConfig:
Expand All @@ -438,6 +439,7 @@ def from_network(network: Network) -> AccountingConfig:
buffer_accounting_config=BufferAccountingConfig.from_network(network),
io_config=IOConfig.from_env(),
data_processing_config=DataProcessingConfig.from_network(network),
network=network,
)


Expand Down
11 changes: 7 additions & 4 deletions src/data_sync/sync_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async def sync_data_to_db( # pylint: disable=too-many-arguments
type_of_data: str,
node: Web3,
orderbook: OrderbookFetcher,
network: str,
config: AccountingConfig,
recompute_previous_month: bool,
) -> None:
Expand All @@ -54,8 +53,14 @@ async def sync_data_to_db( # pylint: disable=too-many-arguments
)
# we note that the block range computed above is meant to be interpreted as
# a closed interval
network_name_map = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you you are trying to get to the dune name of networks. This can already be done by using config.dune_config.dune_blockchain. See #483, where the network is not passed and the dune config is used to get the network name.

"mainnet": "ethereum",
"gnosis": "gnosis",
"arbitrum": "arbitrum",
"base": "base",
}
network_name = network_name_map[config.network.value]
for i, (start_block, end_block) in enumerate(block_range_list):
network_name = "ethereum" if network == "mainnet" else network
table_name = type_of_data + "_data_" + network_name + "_" + months_list[i]
block_range = BlockRange(block_from=start_block, block_to=end_block)
log.info(
Expand Down Expand Up @@ -95,7 +100,6 @@ def sync_data() -> None:
"batch",
web3,
orderbook,
network,
config,
recompute_previous_month=False,
)
Expand All @@ -106,7 +110,6 @@ def sync_data() -> None:
"order",
web3,
orderbook,
network,
config,
recompute_previous_month=False,
)
Expand Down
Loading