Skip to content

Conversation

@owl352
Copy link
Collaborator

@owl352 owl352 commented Sep 24, 2025

dependent #716

Issue

We need to implement endpoints with SSE which allows to get in real time updates of indexer

Things done

  • Implemented endpoints which creates keep-alive connection
  • Implemented redis logic with optional usage and flag, which allows to disable SSE on sync
  • Implemented events based blocks pool, which allows blocks to be sent in the correct order, otherwise the sending order will be disrupted due to different waiting times for several blocks with consecutive transactions or any other delays
  • Implemented getBlockWithTransaction for BlocksDAO
  • Implemented indexer logic with redis pub/sub, which can be disabled by unsetting env vars
  • Added redis flag for indexer, which set to true, when indexer is indexing
  • Implemented class RedisConnection, which allows to interact with redis via only 2 connections
  • API SSE can be also disabled by unsetting env vars

@owl352 owl352 self-assigned this Sep 24, 2025
@owl352 owl352 added the backend Related to backend (API) label Sep 24, 2025
@vercel
Copy link

vercel bot commented Sep 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
platform-explorer Ready Ready Preview Comment Oct 9, 2025 1:10pm

# Conflicts:
#	packages/api/src/dao/TransactionsDAO.js
}

subscribeBlockWithTransactions = async (request, response) => {
await checkSSEConditions(this.redis, this.blocksDAO)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If redis is available, then we can use it, I think we can do it by conditionally passing the redis in the constructor, and handle optionality on creation level

response.raw.writeHead(200, SSE_HEAD)

const redis = await this.redis.duplicate()
await redis.connect()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should handled in the separate RedisClient class

Comment on lines 12 to 13
if last_block_height > current_block_height + 10 {
self.processor.set_indexing_flag(true).await;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use catchingUp from tenderdash RPC

await this.redis.subscribeMessages(callback)

// initialize sse
response.sse({ data: JSON.stringify({ status: 'ok' }) })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return current block in as first message

@owl352 owl352 requested a review from pshenmic October 9, 2025 14:48
@pshenmic pshenmic changed the title API sse Server Sent Events on API Oct 9, 2025
@owl352 owl352 linked an issue Oct 13, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Related to backend (API)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transaction list real time update on homepage

3 participants