Skip to content

Commit 49640e2

Browse files
committed
indexer: don't store pending cursor
1 parent f2182e8 commit 49640e2

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
Apibara Python SDK 0.7.1 (UNRELEASED)
5+
--------------------------------------
6+
7+
Fixed
8+
^^^^^
9+
10+
- Don't store pending cursor to avoid crashing on restart.
11+
12+
413
Apibara Python SDK 0.7.0 (2023-07-08)
514
--------------------------------------
615

src/apibara/indexer/runner.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,20 @@ async def _connect_and_stream(self, indexer: Indexer, ctx: Optional[UserContext]
205205

206206
logger.debug(f"handle batch {cursor} - {end_cursor}")
207207

208-
with self._indexer_storage.create_storage_for_data(
209-
message.data.end_cursor
210-
) as storage:
208+
if is_pending:
209+
create_storage = (
210+
lambda cursor: self._indexer_storage.create_storage_for_pending(
211+
cursor
212+
)
213+
)
214+
else:
215+
create_storage = (
216+
lambda cursor: self._indexer_storage.create_storage_for_data(
217+
cursor
218+
)
219+
)
220+
221+
with create_storage(message.data.end_cursor) as storage:
211222
additional_filter = None
212223
for batch in message.data.data:
213224
decoded_data = indexer.decode_data(batch)

0 commit comments

Comments
 (0)