12
12
from django .conf import settings
13
13
from django .db .models import Count , DecimalField , Q , Sum , Value
14
14
from django .db .models .functions import Cast , NullIf
15
- from near_lake_framework import LakeConfig , streamer
15
+ from near_lake_framework import LakeConfig , streamer , Network
16
16
import stellar_sdk
17
17
from stellar_sdk .soroban_server import EventFilter , EventFilterType
18
18
from stellar_sdk import Address , stellar_xdr , scval
@@ -36,22 +36,16 @@ async def indexer(from_block: int, to_block: int):
36
36
"""
37
37
# Initialize lake indexer
38
38
logger .info (f"from block: { from_block } " )
39
- lake_config = (
40
- LakeConfig .testnet ()
39
+
40
+ lake_config = LakeConfig (
41
+ Network .TESTNET
41
42
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 ,
45
46
from_block
46
- if from_block
47
- else logger .info (
48
- "Starting to index from latest block"
49
- ) # TODO: wtf is this shitty code
50
47
)
51
- lake_config .aws_access_key_id = settings .AWS_ACCESS_KEY_ID
52
- lake_config .aws_secret_key = settings .AWS_SECRET_ACCESS_KEY
53
48
_ , streamer_messages_queue = streamer (lake_config )
54
- block_count = 0
55
49
56
50
while True :
57
51
try :
@@ -63,8 +57,6 @@ async def indexer(from_block: int, to_block: int):
63
57
logger .info (
64
58
f"Time to fetch new block: { fetch_end_time - fetch_start_time :.4f} seconds"
65
59
)
66
- block_count += 1
67
-
68
60
# Log time before caching block height
69
61
save_start_time = time .time ()
70
62
# Update current block height
0 commit comments