Skip to content
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

Refactor websocket address tracking #4095

Merged
merged 2 commits into from
Aug 7, 2023

Conversation

mononaut
Copy link
Contributor

@mononaut mononaut commented Aug 4, 2023

This PR refactors how we handle the track-address websocket subscription in the backend to reduce code duplication and scale better for many simultaneous subscriptions.

Instead of searching the full list of transactions separately for every subscribed client, we build a mini address index cache once up front, from which we can look up tracked addresses in the client update loop in ~constant time.

Building the cache adds a small constant overhead to the $handleMempoolChange and handleNewBlock functions, but the fast lookups maintain performance much better when there are many open address subscriptions.

@cla-bot
Copy link

cla-bot bot commented Aug 4, 2023

Thanks for your contribution to The Mempool Open Source Project. We require all contributors to agree to our Contributor License Agreement and don't seem to have one for you on file. Please see the instructions in CONTRIBUTING.md to proceed with this pull request.

@cla-bot cla-bot bot added the cla-signed label Aug 7, 2023
Copy link
Member

@softsimon softsimon left a comment

Choose a reason for hiding this comment

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

tested ACK @ [38e9021]

@softsimon softsimon merged commit 41eecfa into master Aug 7, 2023
20 checks passed
@softsimon softsimon deleted the mononaut/refactor-address-tracking branch August 7, 2023 03:13
@mononaut mononaut mentioned this pull request Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants