Skip to content

Commit

Permalink
is_finalized property
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Oct 27, 2024
1 parent 3001086 commit d8eb4be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/demo_substrate_events/handlers/on_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ async def on_transfer(
if not amount:
return

await sql_update(ctx, event.payload['from'], -amount, event.data.level)
await sql_update(ctx, event.payload['to'], amount, event.data.level)

# await orm_update(ctx, event.payload['from'], -amount, event.data.level)
# await orm_update(ctx, event.payload['to'], amount, event.data.level)
if ctx.is_finalized:
await sql_update(ctx, event.payload['from'], -amount, event.data.level)
await sql_update(ctx, event.payload['to'], amount, event.data.level)
else:
await orm_update(ctx, event.payload['from'], -amount, event.data.level)
await orm_update(ctx, event.payload['to'], amount, event.data.level)
5 changes: 5 additions & 0 deletions src/dipdup/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,8 @@ def _wrap(
)
ctx._link(new_ctx)
return new_ctx

@property
def is_finalized(self) -> bool:
# FIXME: check the datasource
return 1
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ async def on_transfer(
if not amount:
return

await sql_update(ctx, event.payload['from'], -amount, event.data.level)
await sql_update(ctx, event.payload['to'], amount, event.data.level)

# await orm_update(ctx, event.payload['from'], -amount, event.data.level)
# await orm_update(ctx, event.payload['to'], amount, event.data.level)
if ctx.is_finalized:
await sql_update(ctx, event.payload['from'], -amount, event.data.level)
await sql_update(ctx, event.payload['to'], amount, event.data.level)
else:
await orm_update(ctx, event.payload['from'], -amount, event.data.level)
await orm_update(ctx, event.payload['to'], amount, event.data.level)

0 comments on commit d8eb4be

Please sign in to comment.