DocumentationBlog

Pending data

The Python SDK supports indexing pending data to implement optimistic updates in your application.

Adding support for pending blocks to your application is easy, simply configure the IndexerRunner as follows:

runner.add_pending_events_handler(
handle_pending,
interval_seconds=5
)

where handle_pending is a function with the following signature:

async def handle_pending(info: Info, block_events: NewEvents):
pass

Chain-aware storage#

The chain-aware storage provided by the Python SDK will handle data invalidation for you:

  • On every new pending data, it invalidates all data from the previously handled pending block.
  • On new data blocks, it invalidates any pending data.

Best practices#

  • Don't add dynamic filters in the pending block handler. This is currently not supported.
  • Use an interval_seconds that makes sense for your application.
  • Add an attribute to documents to track wether the document was inserted in an accepted block or in a pending block. Use this information to clearly display data in your application.