8000 Optimize transaction cache by tdroxler · Pull Request #613 · alephium/explorer-backend · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Optimize transaction cache #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 13, 2025
Merged

Optimize transaction cache #613

merged 7 commits into from
May 13, 2025

Conversation

tdroxler
Copy link
Member

Previously in our TransactionCache every 10 minutes we were re-counting every txs in database, not optimal...

In this PR, we take advantage of the FinalizerService, which is grabbing every 10min every txs that needs to be finalized.
Here is the workflow:

  • We keep in our AppState table the current count of finalized txs.
  • When we finalize new txs, we add their count to the finalized_tx_count in app_state
  • The TransactionCache is first reading the finalized_tx_count and only count txs that aren't finalized.

With this solution, whatever the number of transactions, the cache will only count a very small set of transactions.

We were always re-finalizing the previous latest block at the
`latest-finalized-time`.

It's not a big deal, but it's a waste of resource.

Plus when starting without any value in `app_state` for
`finalized_tx_count`, it could lead to few more txs in the count.
@tdroxler tdroxler requested a review from h0ngcha0 April 10, 2025 13:24
Copy link
Member
@h0ngcha0 h0ngcha0 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@tdroxler tdroxler merged commit 237b986 into master May 13, 2025
2 of 3 checks passed
@tdroxler tdroxler deleted the count-transactions branch May 13, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0