1212from django .conf import settings
1313from django .db .models import Count , DecimalField , Q , Sum , Value
1414from django .db .models .functions import Cast , NullIf
15- from near_lake_framework import LakeConfig , streamer
15+ from near_lake_framework import LakeConfig , streamer , Network
1616import stellar_sdk
1717from stellar_sdk .soroban_server import EventFilter , EventFilterType
1818from stellar_sdk import Address , stellar_xdr , scval
@@ -36,22 +36,16 @@ async def indexer(from_block: int, to_block: int):
3636 """
3737 # Initialize lake indexer
3838 logger .info (f"from block: { from_block } " )
39- lake_config = (
40- LakeConfig .testnet ()
39+
40+ lake_config = LakeConfig (
41+ Network .TESTNET
4142 if settings .ENVIRONMENT == "testnet"
42- else LakeConfig . mainnet ()
43- )
44- lake_config . start_block_height = (
43+ else Network . MAINNET ,
44+ settings . AWS_ACCESS_KEY_ID ,
45+ settings . AWS_SECRET_ACCESS_KEY ,
4546 from_block
46- if from_block
47- else logger .info (
48- "Starting to index from latest block"
49- ) # TODO: wtf is this shitty code
5047 )
51- lake_config .aws_access_key_id = settings .AWS_ACCESS_KEY_ID
52- lake_config .aws_secret_key = settings .AWS_SECRET_ACCESS_KEY
5348 _ , streamer_messages_queue = streamer (lake_config )
54- block_count = 0
5549
5650 while True :
5751 try :
@@ -63,8 +57,6 @@ async def indexer(from_block: int, to_block: int):
6357 logger .info (
6458 f"Time to fetch new block: { fetch_end_time - fetch_start_time :.4f} seconds"
6559 )
66- block_count += 1
67-
6860 # Log time before caching block height
6961 save_start_time = time .time ()
7062 # Update current block height
0 commit comments